Delimiter in proc_macro - Rust (original) (raw)
Enum Delimiter
1.29.0 · Source
pub enum Delimiter {
Parenthesis,
Brace,
Bracket,
None,
}
Expand description
Describes how a sequence of token trees is delimited.
§1.29.0
( ... )
§1.29.0
{ ... }
§1.29.0
[ ... ]
§1.29.0
∅ ... ∅
An invisible delimiter, that may, for example, appear around tokens coming from a “macro variable” $var
. It is important to preserve operator priorities in cases like$var * 3
where $var
is 1 + 2
. Invisible delimiters might not survive roundtrip of a token stream through a string.
Note: rustc currently can ignore the grouping of tokens delimited by None
in the output of a proc_macro. Only None
-delimited groups created by a macro_rules macro in the input of a proc_macro macro are preserved, and only in very specific circumstances. Any None
-delimited groups (re)created by a proc_macro will therefore not preserve operator priorities as indicated above. The other Delimiter
variants should be used instead in this context. This is a rustc bug. For details, seerust-lang/rust#67062.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.