Structural Typing for Rust
Define a struct once and use it with different field combinations, tracked at compile time. Inspired by TypeScript, RDF, and this talk.
Status: Experimental. API subject to change.
Installation
If you use derives on your #[structural] structs, also add:
Example
use ;
type Create = select!;
See examples/ for comprehensive usage including merge, extract, serde integration, and more.
Features
- Compile-time field requirements
- Builder API with type inference
- Merge and extract operations
- Serde support (via
serdefeature) - Zero runtime overhead
Constraints
- Named structs only (not tuple structs or enums)
- No generic parameters
- At least one field required
License
MIT OR Apache-2.0