Trait futures_await_quote::ToTokens
[−]
[src]
pub trait ToTokens { fn to_tokens(&self, _: &mut Tokens); fn into_tokens(self) -> Tokens
where
Self: Sized, { ... } }
Types that can be interpolated inside a quote!(...)
invocation.
Required Methods
fn to_tokens(&self, _: &mut Tokens)
Write self
to the given Tokens
.
Example implementation for a struct representing Rust paths like
std::cmp::PartialEq
:
⚠Be careful when using this code, it's not being tested!
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 { tokens.append("::"); } 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.