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§
Sourcefn apply_span(self, span: Self::Span) -> Self
fn apply_span(self, span: Self::Span) -> Self
Apply a span to every TokenTree in the TokenStream, using TokenTree::set_span
Sourcefn expect(
self,
tokens: impl Iterator<Item = Self::TokenTree>,
) -> Option<(Self, Self)>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl TokenStreamExt for TokenStream
Available on crate feature
proc-macro only.impl TokenStreamExt for TokenStream
Available on crate feature
proc-macro2 only.