Expand description
Procedural macro implementation for structible.
This crate provides the #[structible] attribute macro, which transforms
structs into map-backed types with generated accessors. Users should depend
on the main structible crate, which re-exports this macro.
§Design
The macro generates several items from a single struct definition:
- A field enum used as map keys (one variant per field)
- A value enum used as map values (wrapping each field’s type)
- A fields struct for ownership extraction via
into_fields() - The main struct backed by the chosen map type
- An impl block with accessors for all fields
§Invariants
Required fields (non-Option) are guaranteed to be present after
construction. The generated constructor enforces this by requiring values
for all required fields. Getters for required fields return references
directly, not Option, because the field is always present.
§Optional Field Storage
Fields typed as Option<T> are stored as T in the backing map, not as
Option<T>. Presence or absence in the map represents Some or None.
This means:
- Getters return
Option<&T>(present =Some, absent =None) - Setters accept
Option<T>(Someinserts,Noneremoves) - Removers extract the value if present
Attribute Macros§
- structible
- Transforms a struct into a map-backed type with generated accessors.