Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经开始研究转子库,我找到了表达式:
me @ Echo::Server(..) => me.accept(),
这是什么意思以及如何使用@运算符?我的猜测是它类似于强制转换操作,但 Rust 书中关于强制转换的部分没有提到它。
@
你可以使用Rust Book 中的语法索引来查找语法。在这种情况下,它是一个模式绑定,用于将模式的特定部分绑定到一个变量。
在这里,它被用来将整个值绑定到me当且仅当它是一个Echo::Server变体时。
me
Echo::Server