For the same struct member, is it possible to execute if multiple times?
- Dominant language
- Rust
- Stars
- 853
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
I think it might be more appropriate to execute if multiple times or add elif to align with common usage. Below is a demo, where the compiler will throw an error when executing the if statement twice.
#[binread]
pub struct A {
size: u32,
magic: u32,
#[br(if(magic == 0x1, 1), if(magic == 0x2, 3))]
data: Vec,
}
Contributor guide
Research direction
Start by reproducing the reported #[br(if(...), if(...))] example in a minimal binrw crate and inspect how repeated if attributes are parsed and rejected. Define the intended behavior for multiple conditions, including whether the branches are exclusive, then add coverage showing the struct member handles both magic values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100