Structural Typing for Rust
Define structs with optional fields, tracked at the type level. Inspired by TypeScript, RDF, and this talk.
Installation
Example
use ;
// Methods that require specific fields
// Note: #[structural] generates a snake_case module (User → user)
See examples/ for comprehensive usage including merge, split, serde integration, and more.
Features
- Type-level field tracking (
Present,Optional,Absent) - Compile-time enforcement of field requirements
- Builder pattern with
.field()that infers presence from value type - Type-safe merge and split
- Automatic serde support
- Zero runtime overhead
Status
Experimental. API subject to change.
License
MIT OR Apache-2.0