Derive Macro FieldNamesAsArray

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

Derives the FieldNamesAsArray trait.

§Panics

If the token stream is not coming from a named struct or if the field_names_as_array attribute is used wrongfully, deriving this macro will fail.

§Examples

use struct_field_names_as_array::FieldNamesAsArray;

#[derive(FieldNamesAsArray)]
struct Foo {
    bar: String,
    baz: String,
    bat: String,
}

assert_eq!(Foo::FIELD_NAMES_AS_ARRAY, ["bar", "baz", "bat"]);