1.15.0[−][src]Struct proc_macro::TokenStream
The main type provided by this crate, representing an abstract stream of tokens, or, more specifically, a sequence of token trees. The type provide interfaces for iterating over those token trees and, conversely, collecting a number of token trees into one stream.
This is both the input and output of #[proc_macro]
, #[proc_macro_attribute]
and #[proc_macro_derive]
definitions.
Methods
impl TokenStream
[src]
impl TokenStream
pub fn new() -> TokenStream
1.29.0[src]
pub fn new() -> TokenStream
Returns an empty TokenStream
containing no token trees.
pub fn is_empty(&self) -> bool
1.29.0[src]
pub fn is_empty(&self) -> bool
Checks if this TokenStream
is empty.
Trait Implementations
impl !Send for TokenStream
[src]
impl !Send for TokenStream
impl !Sync for TokenStream
[src]
impl !Sync for TokenStream
impl IntoIterator for TokenStream
1.29.0[src]
impl IntoIterator for TokenStream
type Item = TokenTree
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIterfn into_iter(self) -> IntoIter
[src]
fn into_iter(self) -> IntoIter
Creates an iterator from a value. Read more
impl Extend<TokenTree> for TokenStream
1.30.0[src]
impl Extend<TokenTree> for TokenStream
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, trees: I)
[src]
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, trees: I)
Extends a collection with the contents of an iterator. Read more
impl Extend<TokenStream> for TokenStream
1.30.0[src]
impl Extend<TokenStream> for TokenStream
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
[src]
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
Extends a collection with the contents of an iterator. Read more
impl Clone for TokenStream
[src]
impl Clone for TokenStream
fn clone(&self) -> TokenStream
[src]
fn clone(&self) -> TokenStream
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl From<TokenTree> for TokenStream
1.29.0[src]
impl From<TokenTree> for TokenStream
Creates a token stream containing a single token tree.
fn from(tree: TokenTree) -> TokenStream
[src]
fn from(tree: TokenTree) -> TokenStream
Performs the conversion.
impl Display for TokenStream
[src]
impl Display for TokenStream
Prints the token stream as a string that is supposed to be losslessly convertible back
into the same token stream (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters and negative numeric literals.
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for TokenStream
[src]
impl Debug for TokenStream
Prints token in a form convenient for debugging.
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl FromIterator<TokenTree> for TokenStream
1.29.0[src]
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self
Creates a value from an iterator. Read more
impl FromIterator<TokenStream> for TokenStream
[src]
impl FromIterator<TokenStream> for TokenStream
A "flattening" operation on token streams, collects token trees from multiple token streams into a single stream.
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
Creates a value from an iterator. Read more
impl FromStr for TokenStream
[src]
impl FromStr for TokenStream
Attempts to break the string into tokens and parse those tokens into a token stream.
May fail for a number of reasons, for example, if the string contains unbalanced delimiters
or characters not existing in the language.
All tokens in the parsed stream get Span::call_site()
spans.
NOTE: Some errors may cause panics instead of returning LexError
. We reserve the right to
change these errors into LexError
s later.
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
impl<I> IntoIterator for I where
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
fn into_iter(self) -> I
Creates an iterator from a value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
#41263)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
#27745)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<E> SpecializationError for E
[src]
impl<E> SpecializationError for E
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
[src]
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
🔬 This is a nightly-only experimental API. (rustc_private
#27812)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S
is the encoder/decoder state type, T
is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more
impl<T> Send for T where
T: ?Sized,
[src]
impl<T> Send for T where
T: ?Sized,
impl<T> Sync for T where
T: ?Sized,
[src]
impl<T> Sync for T where
T: ?Sized,
impl<T> Erased for T
[src]
impl<T> Erased for T
impl<T> Erased for T
impl<T> Erased for T