structural-convert
Derive conversion traits when items are structurally similar.
Inspired by serde and struct-convert crates.
Features
- One to one fields mapping derive for
- From
- Into
- TryFrom
- TryInto
- Inner fields type conversion using
.into()/.try_into() - Field skip functionality when deriving for From and TryFrom
Features Wishlist
- Rename fields
- Fallback to default per variant/field
- Skipping fields for Into / TryInto, for:
- Unnamed Enum variants
- Named Enum variants
- Unnamed Struct fields
- Named Struct fields
Examples
Check the tests folder for more examples, but here is some samples:
Struct
assert_eq!;
assert_eq!;
Generated code:
Enum
assert_eq!;
Generated code: