3

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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Sergey
  • 145
  • 1
  • 6

1 Answers1

4

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.

DK.
  • 55,277
  • 5
  • 189
  • 162