#[derive(Property, Export)] for enums by patataofcourse · Pull Request #371 · godot-rust/gdext (original) (raw)
MVP macros for deriving Property and Export in enums.
Not done yet, but hoping for reviews since this is my first contribution to a library of this size.
Commits will be squashed later, please review as one for now.
Current requirements for deriving these traits:
- Must be an enum
- Must have an explicit
#[repr(i*/u*)]
type - Variants must be unit/fieldless and have explicit discriminant numbers (
A = 2
instead ofA(u32) = 2
orA
)
From earlier attempts, it seemed like ToVariant and FromVariant were needed as well? Doesn't seem to be the case anymore, weirdly.
TODO list:
#[derive(Property)]
- Implement
- Create tests
- Document
- Expand support?
#[derive(Export)]
- Implement
- Create tests
- Document
- Expand support?