[][src]Struct quote::Tokens

pub struct Tokens(_);

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

Methods

impl Tokens[src]

pub fn new() -> Self[src]

Empty tokens.

pub fn append<T: AsRef<str>>(&mut self, token: T)[src]

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");

pub fn append_all<T, I>(&mut self, iter: I) where
    T: ToTokens,
    I: IntoIterator<Item = T>, 
[src]

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");

pub fn append_separated<T, I, S: AsRef<str>>(&mut self, iter: I, sep: S) where
    T: ToTokens,
    I: IntoIterator<Item = T>, 
[src]

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");

pub fn append_terminated<T, I, S: AsRef<str>>(&mut self, iter: I, term: S) where
    T: ToTokens,
    I: IntoIterator<Item = T>, 
[src]

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 ,");

pub fn as_str(&self) -> &str[src]

pub fn into_string(self) -> String[src]

pub fn parse<T: FromStr>(&self) -> Result<T, T::Err>[src]

Trait Implementations

impl ToTokens for Tokens[src]

impl Eq for Tokens[src]

impl Default for Tokens[src]

impl Clone for Tokens[src]

impl AsRef<str> for Tokens[src]

impl PartialEq<Tokens> for Tokens[src]

impl Debug for Tokens[src]

impl Display for Tokens[src]

Auto Trait Implementations

impl Send for Tokens

impl Unpin for Tokens

impl Sync for Tokens

impl UnwindSafe for Tokens

impl RefUnwindSafe for Tokens

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]