Struct syntex_syntax::tokenstream::TokenStream [] [src]

pub struct TokenStream { /* fields omitted */ }

Token Streams

TokenStreams are a syntactic abstraction over TokenTrees. The goal is for procedural macros to work over TokenStreams instead of arbitrary syntax. For now, however, we are going to cut a few corners (i.e., use some of the AST structure) when we need to for backwards compatibility. TokenStreams are collections of TokenTrees that represent a syntactic structure. The struct itself shouldn't be directly manipulated; the internal structure is not stable, and may be changed at any time in the future. The operators will not, however (except for signatures, later on).

Methods

impl TokenStream
[src]

TokenStream operators include basic destructuring, boolean operations, maybe_... operations, and maybe_..._prefix operations. Boolean operations are straightforward, indicating information about the structure of the stream. The maybe_... operations return Some<...> if the tokenstream contains the appropriate item.

Similarly, the maybe_..._prefix operations potentially return a partially-destructured stream as a pair where the first element is the expected item and the second is the remainder of the stream. As anb example,

maybe_path_prefix("a::b::c(a,b,c).foo()") -> (a::b::c, "(a,b,c).foo()")

Convert a vector of TokenTrees into a TokenStream.

Convert a vector of Tokens into a TokenStream.

Manually change a TokenStream's span.

Concatenates two TokenStreams into a new TokenStream.

Indicate if the TokenStream is empty.

Return a TokenStream's length.

Convert a TokenStream into a vector of borrowed TokenTrees.

Convert a TokenStream into a vector of TokenTrees (by cloning the TokenTrees). (This operation is an O(n) deep copy of the underlying structure.)

Return the TokenStream's span.

Returns an iterator over a TokenStream (as a sequence of TokenTrees).

Splits a TokenStream based on the provided &TokenTree -> bool predicate.

Produce a slice of the input TokenStream from the from index, inclusive, to the to index, non-inclusive.

Slice starting at the provided index, inclusive.

Slice up to the provided index, non-inclusive.

Indicates where the stream is a single, delimited expression (e.g., (a,b,c) or {a,b,c}).

Returns the inside of the delimited term as a new TokenStream.

Indicates if the stream is exactly one identifier.

Returns an identifier

Compares two TokenStreams, checking equality without regarding span information.

Convert a vector of TokenTrees into a parentheses-delimited TokenStream.

Trait Implementations

impl Clone for TokenStream
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for TokenStream
[src]

impl Hash for TokenStream
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl Encodable for TokenStream
[src]

Serialize a value using an Encoder.

impl Decodable for TokenStream
[src]

Deserialize a value using a Decoder.

impl Debug for TokenStream
[src]

Formats the value using the given formatter.

impl PartialEq<TokenStream> for TokenStream
[src]

Checks if two TokenStreams are equivalent (including spans). For unspanned equality, see eq_unspanned.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for TokenStream
[src]

Formats the value using the given formatter.

impl Index<usize> for TokenStream
[src]

The returned type after indexing

The method for the indexing (container[index]) operation