Derive Macro FieldNamesAsSlice

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

Derives the FieldNamesAsSlice 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::FieldNamesAsSlice;

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

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