Expand description
§Token Streams
TokenStreams represent syntactic objects before they are converted into ASTs.
A TokenStream is, roughly speaking, a sequence of TokenTrees,
which are themselves a single Token or a Delimited subsequence of tokens.
§Ownership
TokenStreams are persistent data structures constructed as ropes with reference
counted-children. In general, this means that calling an operation on a TokenStream
(such as slice) produces an entirely new TokenStream from the borrowed reference to
the original. This essentially coerces TokenStreams into “views” of their subparts,
and a borrowed TokenStream is sufficient to build an owned TokenStream without taking
ownership of the original.
Modules§
Structs§
- Attr
Token Stream - An
AttrTokenStreamis similar to aTokenStream, but with extra information about the tokens for attribute targets. This is used during expansion to perform early cfg-expansion, and to process attributes during proc-macro invocations. - Attrs
Target - Stores the tokens for an attribute target, along with its attributes.
- Delim
Spacing - Delim
Span - Lazy
Attr Token Stream - A lazy version of
TokenStream, which defers creation of an actualTokenStreamuntil it is needed.Boxis here only to reduce the structure size. - Token
Stream - A
TokenStreamis an abstract sequence of tokens, organized intoTokenTrees. - Token
Stream Iter
Enums§
- Attr
Token Tree - Like
TokenTree, but forAttrTokenStream. - Spacing
- Indicates whether a token can join with the following token to form a
compound token. Used for conversions to
proc_macro::Spacing. Also used to guide pretty-printing, which is where theJointHiddenvalue (which isn’t part ofproc_macro::Spacing) comes in useful. - Token
Tree - Part of a
TokenStream.