pub trait TokenStreamExt: ProcMacroExt<TokenStreamExt = Self> + TokenStream + FromStrDebug {
    // Provided methods
    fn apply_span(self, span: Self::Span) -> Self { ... }
    fn expect(
        self,
        tokens: impl Iterator<Item = Self::TokenTree>
    ) -> Option<(Self, Self)> { ... }
}
Expand description

Extensions for TokenStream.

This trait is implemented for TokenStream in proc_macro and proc_macro2 if the corresponding feature is enabled.

Provided Methods§

source

fn apply_span(self, span: Self::Span) -> Self

Apply a span to every TokenTree in the TokenStream, using TokenTree::set_span

source

fn expect( self, tokens: impl Iterator<Item = Self::TokenTree> ) -> Option<(Self, Self)>

Match tokens and split the TokenStream. The first value in the returned tuple is a TokenStream with the matched tokens (taken from self), and the second is the rest of the TokenStream with the matching tokens removed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TokenStreamExt for TokenStream

Available on crate feature proc-macro only.
source§

impl TokenStreamExt for TokenStream

Available on crate feature proc-macro2 only.

Implementors§