ToTokens

Derive Macro ToTokens 

Source
#[derive(ToTokens)]
{
    // Attributes available to this derive:
    #[to_tokens]
    #[field]
}
Expand description

Implements TokenizeSelf for a struct or enum. All fields must also implement TokenizeSelf.

If the type is a struct with private fields, please use the to_tokens attribute to specify a constructor accepting all fields in the order they are defined.

TokenizeSelf is implemented for primitives and some other common types, please open a pr if you want to add support for a type in an external crate.

§Example

#[derive(ToTokens)]
#[to_tokens(Foo::new)]
struct Foo{
  bar: String,
}

impl Foo{
  pub fn new(bar: String) -> Self {
    Self { bar }
  }
}