StructToArray

Derive Macro StructToArray 

Source
#[derive(StructToArray)]
{
    // Attributes available to this derive:
    #[struct_to_array]
}
Expand description

Derive struct_to_array::StructToArray<Item, N> for a struct whose fields are all the same type (token-identical).

Supported:

  • named-field structs: struct Foo { a: T, b: T }
  • tuple structs: struct Foo(T, T)

Not supported:

  • unit structs: struct Foo;
  • structs with zero fields (no way to infer Item)

Optional attribute:

  • #[struct_to_array(crate = "path_ident")] Use if you renamed the struct_to_array dependency in Cargo.toml. Example: struct_to_array = { package = "struct_to_array", version = "...", package = "...", default-features = false } (you usually won’t need this; proc-macro-crate handles common renames)