meithecatte/enumflags2

`set` API on `BitFlags` for conditional `insert`/`remove`

Closed this issue · 1 comments

The bitflags crate implements this method:

/// Call [`Flags::insert`] when `value` is `true` or [`Flags::remove`] when `value` is `false`.
fn set(&mut self, other: Self, value: bool)
where
    Self: Sized,
{
    if value {
        self.insert(other);
    } else {
        self.remove(other);
    }
}

It allows setting a specific flag(set) conditionally, which is common for status registers.

Implemented in #50 – thanks! I'll see if I have any energy to get anything else into the next release. If this sits on master for a few days with no movement, feel free to ping me.