[−][src]Trait quote::ToTokens
Types that can be interpolated inside a quote!
invocation.
Required Methods
fn to_tokens(&self, tokens: &mut Tokens)
Write self
to the given Tokens
.
Example implementation for a struct representing Rust paths like
std::cmp::PartialEq
:
extern crate quote; use quote::{Tokens, ToTokens}; extern crate proc_macro2; use proc_macro2::{TokenTree, TokenNode, Spacing, Span}; pub struct Path { pub global: bool, pub segments: Vec<PathSegment>, } impl ToTokens for Path { fn to_tokens(&self, tokens: &mut Tokens) { for (i, segment) in self.segments.iter().enumerate() { if i > 0 || self.global { // Double colon `::` tokens.append(TokenTree { span: Span::def_site(), kind: TokenNode::Op(':', Spacing::Joint), }); tokens.append(TokenTree { span: Span::def_site(), kind: TokenNode::Op(':', Spacing::Alone), }); } segment.to_tokens(tokens); } } }
Provided Methods
fn into_tokens(self) -> Tokens where
Self: Sized,
Self: Sized,
Convert self
directly into a Tokens
object.
This method is implicitly implemented using to_tokens
, and acts as a
convenience method for consumers of the ToTokens
trait.
Implementations on Foreign Types
impl<'a, T: ?Sized + ToTokens> ToTokens for &'a T
[src]
impl<'a, T: ?Sized + ToTokens> ToTokens for &'a T
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl<'a, T: ?Sized + ToOwned + ToTokens> ToTokens for Cow<'a, T>
[src]
impl<'a, T: ?Sized + ToOwned + ToTokens> ToTokens for Cow<'a, T>
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl<T: ?Sized + ToTokens> ToTokens for Box<T>
[src]
impl<T: ?Sized + ToTokens> ToTokens for Box<T>
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl<T: ToTokens> ToTokens for Option<T>
[src]
impl<T: ToTokens> ToTokens for Option<T>
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for str
[src]
impl ToTokens for str
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for String
[src]
impl ToTokens for String
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for i8
[src]
impl ToTokens for i8
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for i16
[src]
impl ToTokens for i16
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for i32
[src]
impl ToTokens for i32
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for i64
[src]
impl ToTokens for i64
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for isize
[src]
impl ToTokens for isize
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for u8
[src]
impl ToTokens for u8
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for u16
[src]
impl ToTokens for u16
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for u32
[src]
impl ToTokens for u32
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for u64
[src]
impl ToTokens for u64
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for usize
[src]
impl ToTokens for usize
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for f32
[src]
impl ToTokens for f32
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for f64
[src]
impl ToTokens for f64
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for char
[src]
impl ToTokens for char
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for bool
[src]
impl ToTokens for bool
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for Term
[src]
impl ToTokens for Term
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for Literal
[src]
impl ToTokens for Literal
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for TokenNode
[src]
impl ToTokens for TokenNode
fn to_tokens(&self, tokens: &mut Tokens)
[src]
fn to_tokens(&self, tokens: &mut Tokens)
fn into_tokens(self) -> Tokens where
Self: Sized,
[src]
fn into_tokens(self) -> Tokens where
Self: Sized,
impl ToTokens for TokenTree
[src]
impl ToTokens for TokenTree
impl ToTokens for TokenStream
[src]
impl ToTokens for TokenStream