rust-lang / rust-lang/rust-bindgen

Derive `Default` for rustified enums.

Open
#3,308 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.