简体   繁体   中英

Use of internal rules in Rust macros 2.0

I cannot understand where lazy-static's @TAIL and @MAKE have been defined and their particular use cases.

If I've understood internal rules correctly, the primary usage of @as_expr in the example is to hide as_expr! (or in general, previously defined macros) from being exported ie it's a way of altering the global macro namespace. Following that, then @TAIL or @MAKE should already be a macro while I cannot find them in the lazy_static source .

You linked to the definitions. @TAIL is right there three lines down on 137, @MAKE is on 162.

@name is not special in any way whatsoever. There is absolutely no special behaviour. It's just a sequence of tokens that cannot show up in "normal" code, and is thus unlikely to be accidentally matched to other rules. @as_expr does not hide an as_expr! macro, it's used instead of defining a publicly visible as_expr! macro.

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