Struct rustc_ast::tokenstream::TokenStream
source · [−]pub struct TokenStream(pub(crate) Lrc<Vec<TreeAndSpacing>>);Expand description
A TokenStream is an abstract sequence of tokens, organized into TokenTrees.
The goal is for procedural macros to work with TokenStreams and TokenTrees
instead of a representation of the abstract syntax tree.
Today’s TokenTrees can still contain AST via token::Interpolated for
backwards compatibility.
Tuple Fields
0: Lrc<Vec<TreeAndSpacing>>Implementations
sourceimpl TokenStream
impl TokenStream
sourceimpl TokenStream
impl TokenStream
pub fn new(streams: Vec<TreeAndSpacing>) -> TokenStream
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn from_streams(streams: SmallVec<[TokenStream; 2]>) -> TokenStream
pub fn trees(&self) -> CursorⓘNotable traits for Cursorimpl Iterator for Cursor type Item = TokenTree;
pub fn into_trees(self) -> CursorⓘNotable traits for Cursorimpl Iterator for Cursor type Item = TokenTree;
sourcepub fn eq_unspanned(&self, other: &TokenStream) -> bool
pub fn eq_unspanned(&self, other: &TokenStream) -> bool
Compares two TokenStreams, checking equality without regarding span information.
pub fn map_enumerated<F: FnMut(usize, &TokenTree) -> TokenTree>(
self,
f: F
) -> TokenStream
Trait Implementations
sourceimpl Clone for TokenStream
impl Clone for TokenStream
sourcefn clone(&self) -> TokenStream
fn clone(&self) -> TokenStream
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for TokenStream
impl Debug for TokenStream
sourceimpl Default for TokenStream
impl Default for TokenStream
sourcefn default() -> TokenStream
fn default() -> TokenStream
Returns the “default value” for a type. Read more
sourceimpl<__E: Encoder> Encodable<__E> for TokenStream
impl<__E: Encoder> Encodable<__E> for TokenStream
sourceimpl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
sourcefn from(tree: TokenTree) -> TokenStream
fn from(tree: TokenTree) -> TokenStream
Performs the conversion.
sourceimpl FromIterator<TokenTree> for TokenStream
impl FromIterator<TokenTree> for TokenStream
sourcefn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<CTX> HashStable<CTX> for TokenStream where
CTX: HashStableContext,
impl<CTX> HashStable<CTX> for TokenStream where
CTX: HashStableContext,
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
sourceimpl PartialEq<TokenStream> for TokenStream
impl PartialEq<TokenStream> for TokenStream
impl Eq for TokenStream
Auto Trait Implementations
impl !RefUnwindSafe for TokenStream
impl !Send for TokenStream
impl !Sync for TokenStream
impl Unpin for TokenStream
impl !UnwindSafe for TokenStream
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes