#[derive(ToTokenStream)]
{
// Attributes available to this derive:
#[OutType]
}
Expand description
Implement ToTokenStream for a struct or enum with components implementating ToTokenStream.
§Basic usage
use rustifact::ToTokenStream;
#[derive(ToTokenStream)]
pub struct MyStruct {
// fields...
}
#[derive(ToTokenStream)]
pub enum MyEnum {
// variants...
}§Type mapping
In the case that some components change type under ToTokenStream, like for example String which is mapped to &’static str, a separate output type may be specified with the OutType attribute.
§
use rustifact::ToTokenStream;
pub struct StructWithStr {
pub s: &'static str,
}
#[derive(ToTokenStream)]
#[OutType(StructWithStr)]
pub struct StructWithStrIn {
pub s: String,
}