rust-lang / rust-lang/rust-bindgen
Derive `Default` for rustified enums.
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Hello, I have bindgen.derive_default(true), but rustified_enum types don't have a default impl.
Can we either:
- Derive default if there is a variant that equals to 0
- Derive default if a first variant that equals to 0
- Derive default to be the first variant
I tried looking through the source code of bindgen, but I didn't manage to grasp where the changes should be made.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how bindgen handles rustified_enum generation and how bindgen.derive_default(true) is applied. Resolve which proposed rule determines the default variant, then verify that generated rustified enums implement Default accordingly and add coverage for the selected zero or first-variant behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100