#[structible]Expand description
Transforms a struct into a map-backed type with generated accessors.
§Example
ⓘ
use structible::structible;
#[structible(HashMap)]
pub struct Person {
pub name: String,
pub age: u32,
pub email: Option<String>,
}This generates:
- A field enum for map keys (one variant per field)
- A value enum for map values (wrapping each field type)
- A
PersonFieldsstruct for ownership extraction - The
Personstruct backed byHashMap - Getters, setters, and removers for each field
§Optional Fields
Fields typed as Option<T> are stored without the Option wrapper.
Presence in the map represents Some, absence represents None:
email()returnsOption<&String>set_email(v)inserts the valueremove_email()removes and returns the value if present
§Required Fields
Non-optional fields are guaranteed present after construction:
name()returns&String(notOption)set_name(v)replaces the value- Use
into_fields()thentake_name()to extract owned value