Ehsan M. Kermani
Ehsan M. Kermani

Reputation: 952

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 i.e. 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.

Upvotes: 0

Views: 640

Answers (1)

DK.
DK.

Reputation: 58975

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.

Upvotes: 3

Related Questions