Fix repeated input evaluation in bitflags_match! #499
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bitflags-match-evaluate-once"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Evaluate the input once without moving it. Add regression tests for later-arm matches, fallback matches, default-only invocations, and non-Copy inputs. Verified with cargo test --all-features and cargo fmt --all -- --check.
bitflags_match!could evaluate its input repeatedly—once per attempted match—instead of once overall.So
bitflags_match!(next_flags(), …)could callnext_flags()several times and match against different values. With only a default arm, it never called it.The fix evaluates the input once and reuses it without moving it. Four regression tests cover this.
Thanks @christophacham!