use duplicate::*;
struct Example{one: u8, two: u8}
#[substitute_item(
members [
duplicate!{
[
mem; [one]; [two]
]
mem: 0,
}
];
)]impl Example {
fn inline_new() -> Self {
Example {members}
}
fn attr_new() -> Self {
Example {members}
}
}
#[substitute_item(
name [StructName1];
duplicate!{
[
nam typ;
[typ1 ] [u8];
]
nam [typ];
}
typ2 [u16];
)]struct name(typ1,typ2);
#[duplicate_item(
name typ1 typ2;
[TypeName21]
duplicate!{
[
typ; [u8]
]
[typ]
}
[u16];
)]struct name(typ1, typ2);
#[duplicate_item(
v1; [u8]; [u16];
)]#[duplicate_item(
v2; [u32, v1]; [u64, v1];
)]impl std::error::Error<v2> for (){}
trait SomeType<T1,T2,T3>{}
#[duplicate_item(
v1; [u8]; [u16];
)]#[duplicate_item(
v2; [u32, v1]; [u64, v1];
)]#[duplicate_item(
v3; [i8, v2]; [i16, v2];
)]impl SomeType<v3> for (){}
struct Example2{one: u8}
#[substitute_item(
member [
substitute!{
[
mem [one];
]
mem: 0,
}
];
)]const SOME_STRUCT1: Example2 = Example2{member};
#[duplicate_item(
name member;
[SOME_STRUCT2] [
substitute!{
[
mem [one];
]
mem: 1,
}
];
[SOME_STRUCT3] [
substitute!{
[
val [2];
]
one: val,
}
];
)]const name: Example2 = Example2{member};