简体   繁体   中英

What does @ mean in a match statement?

I've started to study the rotor library and I've found the expression :

me @ Echo::Server(..) => me.accept(),

What does this mean and how do I use the @ operator? My guess is that it is something like a cast operation, but the Rust book's section about casting doesn't mention it.

You can use the syntax index in the Rust Book to look up bits of syntax. In this case, it's a pattern binding , used to bind a specific part of a pattern to a variable.

Here, it's being used to bind the entire value to me if and only if it is an Echo::Server variant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM