Struct quote::Tokens [] [src]

pub struct Tokens(_);

Tokens produced by a quote!(...) invocation.

Methods

impl Tokens
[src]

Empty tokens.

For use by ToTokens implementations.

struct X;

impl ToTokens for X {
    fn to_tokens(&self, tokens: &mut Tokens) {
        tokens.append("a");
        tokens.append("b");
        tokens.append("c");
    }
}

let tokens = quote!(#X);
assert_eq!(tokens.as_str(), "a b c");

For use by ToTokens implementations.

struct X;

impl ToTokens for X {
    fn to_tokens(&self, tokens: &mut Tokens) {
        tokens.append_all(&[true, false]);
    }
}

let tokens = quote!(#X);
assert_eq!(tokens.as_str(), "true false");

For use by ToTokens implementations.

struct X;

impl ToTokens for X {
    fn to_tokens(&self, tokens: &mut Tokens) {
        tokens.append_separated(&[true, false], ",");
    }
}

let tokens = quote!(#X);
assert_eq!(tokens.as_str(), "true , false");

For use by ToTokens implementations.

struct X;

impl ToTokens for X {
    fn to_tokens(&self, tokens: &mut Tokens) {
        tokens.append_terminated(&[true, false], ",");
    }
}

let tokens = quote!(#X);
assert_eq!(tokens.as_str(), "true , false ,");

Trait Implementations

impl Debug for Tokens
[src]

Formats the value using the given formatter.

impl Clone for Tokens
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for Tokens
[src]

impl PartialEq for Tokens
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Default for Tokens
[src]

Returns the "default value" for a type. Read more

impl Display for Tokens
[src]

Formats the value using the given formatter. Read more

impl AsRef<str> for Tokens
[src]

Performs the conversion.

impl ToTokens for Tokens
[src]

Write self to the given Tokens. Read more