Expand description
This module contains the transforming parsers. This are the parsers that add, remove, replace or reorder Tokens while parsing.
Note: When the proc_macro2 feature is disabled, IntoIdent<T> is not available
because it requires parsing from strings (&str.into_token_iter()) which is only
available with proc_macro2.
Structs§
- Discard
- Succeeds when the next token matches
T. The token will be removed from the stream but not stored. Consequently theToTokensimplementations will panic with a message that it can not be emitted. This can only be used when a token should be present but not stored and never emitted. - Insert
- Injects tokens without parsing anything.
- Into
Ident - Parses
Tand concats all its elements to a single identifier by removing all characters that are not valid in identifiers. WhenTimplementsDefault, such as single string (non group) keywords, operators andConst*literals. Then it can be used to createIntoIdentifieron the fly. Note that construction may still fail when one tries to create a invalid identifier such as one starting with digits for example. - Into
Literal String - Parses
Tand creates aLiteralStringfrom it. WhenTimplementsDefault, such as single string (non group) keywords, operators andConst*literals. It can be used to createIntoLiteralStringon the fly. - Into
Token Stream - Parses
Tand keeps it as opaqueTokenStream. This is useful when one wants to parse a sequence of tokens and keep it as opaque unit or re-parse it later as something else. - Skip
- Skips over expected tokens. Will parse and consume the tokens but not store them.
Consequently the
ToTokensimplementations will not output any tokens. - Swap
- Swaps the order of two entities.
Type Aliases§
- AsDefault
- Parse a
Tand replace it with its default value. This is a zero sized type. It can be used for no allocation replacement elements in aVecsince it has a optimization for zero-sized-types where it wont allocate any memory but just act as counter then. - OrDefault
- Tries to parse a
Tor inserts aDwhen that fails. - Replace
- Parse-skip a
Tand inserts aU: Defaultin place. This is a zero sized type. - Token
Stream Until - Parses a
TokenStreamuntil, but excludingT. The presence ofTis mandatory.