How it works...
Parameter ranges in Rust's macro system work a little bit like regular expressions. There are several parts to the syntax: $() indicates repetition, the character that follows its separator (,, ;, and => are allowed), and lastly, the qualifier for how often the repetition is expected (+ or *—just like regular expressions, one or more and zero or more respectively).
Step 2 shows the implementation of a set initializer macro akin to vec!. There, we expect a single expression to populate std::collections::HashSet and return the result in a sub-block from the transcriber. This is necessary to allow things such as variable assignments (which are not allowed directly within the transcriber block), but don't hinder the expansion ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access