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 x = X;
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 x = X;
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 x = X;
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 x = X;
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.

impl ToTokens for Tokens
[src]

Write self to the given Tokens. Read more