pub struct TokenStream {
pub tokens: Vec<TokenTree>,
pub metadata: TokenStreamMetadata,
}Expand description
An abstract stream of Cairo tokens.
This is both input and part of an output of a procedural macro.
Fields§
§tokens: Vec<TokenTree>§metadata: TokenStreamMetadataImplementations§
Source§impl TokenStream
impl TokenStream
Sourcepub fn new(tokens: Vec<TokenTree>) -> Self
pub fn new(tokens: Vec<TokenTree>) -> Self
Create a new TokenStream from a vector of TokenTrees.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create a new empty TokenStream.
Sourcepub fn metadata(&self) -> &TokenStreamMetadata
pub fn metadata(&self) -> &TokenStreamMetadata
Get [TokenStreamMetadata] associated with this TokenStream.
The metadata struct can be used to describe the TokenStream origin.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the TokenStream is empty.
pub fn from_primitive_token_stream( stable_token_stream: impl Iterator<Item = PrimitiveToken>, ) -> Self
pub fn push_token(&mut self, token_tree: TokenTree)
Trait Implementations§
Source§impl Clone for TokenStream
impl Clone for TokenStream
Source§fn clone(&self) -> TokenStream
fn clone(&self) -> TokenStream
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenStream
impl Debug for TokenStream
Source§impl Display for TokenStream
impl Display for TokenStream
Source§impl Extend<TokenStream> for TokenStream
impl Extend<TokenStream> for TokenStream
Source§fn extend<T: IntoIterator<Item = TokenStream>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = TokenStream>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl Extend<TokenTree> for TokenStream
impl Extend<TokenTree> for TokenStream
Source§fn extend<T: IntoIterator<Item = TokenTree>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = TokenTree>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl Hash for TokenStream
impl Hash for TokenStream
Source§impl IntoIterator for TokenStream
impl IntoIterator for TokenStream
Source§impl PartialEq for TokenStream
impl PartialEq for TokenStream
Source§impl ToPrimitiveTokenStream for TokenStream
impl ToPrimitiveTokenStream for TokenStream
impl Eq for TokenStream
impl StructuralPartialEq for TokenStream
Auto Trait Implementations§
impl Freeze for TokenStream
impl !RefUnwindSafe for TokenStream
impl !Send for TokenStream
impl !Sync for TokenStream
impl Unpin for TokenStream
impl !UnwindSafe for TokenStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more