匹配语句中的 @ 是什么意思?
What does @ mean in a match statement?
我开始学习了the rotor library and I've found the expression:
me @ Echo::Server(..) => me.accept(),
这是什么意思,我该如何使用 @
运算符?我的猜测是它类似于强制转换操作,但 Rust 书中的 section about casting 没有提到它。
您可以使用 syntax index in the Rust Book to look up bits of syntax. In this case, it's a pattern binding,用于将模式的特定部分绑定到变量。
在这里,当且仅当它是 Echo::Server
变体时,它才用于将整个值绑定到 me
。
我开始学习了the rotor library and I've found the expression:
me @ Echo::Server(..) => me.accept(),
这是什么意思,我该如何使用 @
运算符?我的猜测是它类似于强制转换操作,但 Rust 书中的 section about casting 没有提到它。
您可以使用 syntax index in the Rust Book to look up bits of syntax. In this case, it's a pattern binding,用于将模式的特定部分绑定到变量。
在这里,当且仅当它是 Echo::Server
变体时,它才用于将整个值绑定到 me
。