Expand description
Types that can be interpolated inside a quote!
invocation.
Write self
to the given TokenStream
.
The token append methods provided by the TokenStreamExt
extension
trait may be useful for implementing ToTokens
.
Example implementation for a struct representing Rust paths like
std::cmp::PartialEq
:
use proc_macro2::{TokenTree, Spacing, Span, Punct, TokenStream};
use quote::{TokenStreamExt, ToTokens};
pub struct Path {
pub global: bool,
pub segments: Vec<PathSegment>,
}
impl ToTokens for Path {
fn to_tokens(&self, tokens: &mut TokenStream) {
for (i, segment) in self.segments.iter().enumerate() {
if i > 0 || self.global {
tokens.append(Punct::new(':', Spacing::Joint));
tokens.append(Punct::new(':', Spacing::Alone));
}
segment.to_tokens(tokens);
}
}
}
Convert self
directly into a TokenStream
object.
This method is implicitly implemented using to_tokens
, and acts as a
convenience method for consumers of the ToTokens
trait.
Convert self
directly into a TokenStream
object.
This method is implicitly implemented using to_tokens
, and acts as a
convenience method for consumers of the ToTokens
trait.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature full
only.
This is supported on crate feature full
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.
This is supported on crate feature printing
only.