Derive Macro Fields

Source
#[derive(Fields)]
Expand description

A derive macro implements the Fields trait for a struct.

Fields can annotate a named struct, a unit struct or an empty unnamed (tuple-like) struct, including generic structs. It collects names of the fields from the struct definition and represents them as a list of string literals accessible through Fields::fields().

#[derive(Fields)]
struct NamedStruct {
    one: String,
    two: u32,
    three: char,
}
assert_eq!(NamedStruct::fields(), ["one", "two", "three"]);