Add .set method (condition-based insert/remove) #55

Merged
mehcode merged 1 commit from master into master 2016-12-26 00:01:33 -06:00
mehcode commented 2016-12-22 02:52:14 -06:00 (Migrated from github.com)
let f = FlagA | FlagC;
f.set(FlagB, true);  // equivalent to f.insert(FlagB)
f.set(FlagA, false);  // equivalent to f.remove(FlagA)

This adds a convenience method to explicitly set the value of a bit. I, at least, use this pattern heavily in https://github.com/mehcode/wadatsumi (A gameboy emulator) so I'm proposing this.

```rust let f = FlagA | FlagC; f.set(FlagB, true); // equivalent to f.insert(FlagB) f.set(FlagA, false); // equivalent to f.remove(FlagA) ``` This adds a convenience method to explicitly set the value of a bit. I, at least, use this pattern heavily in https://github.com/mehcode/wadatsumi (A gameboy emulator) so I'm proposing this.
alexcrichton commented 2016-12-26 00:01:35 -06:00 (Migrated from github.com)

Thanks!

Thanks!
Sign in to join this conversation.
No reviewers
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-bitflags/bitflags!55
No description provided.