rusterlium / rusterlium/rustler
Add attribute keep_case for NifUnitEnum
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.9k
- Forks
- 246
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 7
Description
NifUnitEnum currently expects atoms corresponding to struct fields to be in snake case. This works fine when the user can define the atoms to be in snake case. If that is not possible, e.g. because they are defined by a third party, then decoding them with NifUnitEnum is not possible.
I suggest we add an attribute keep_case which defines that the fields are to be used exactly as-is as atoms.
#[derive(NifUnitEnum)]
#[rustler(keep_case)]
pub struct KeepCase {
UPPERCASE,
lowercase
}
Contributor guide
No contributing guide indexed for this repository
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 in rustler_codegen/src/unit_enum.rs around the snake-case conversion referenced by the issue, and trace how NifUnitEnum attributes are parsed. Done means the keep_case attribute allows enum fields such as UPPERCASE and lowercase to be used exactly as atom names, while existing behavior remains unchanged.
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
- Clearly specified
- Newbie friendliness
- 45/100