We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
set
1 parent dc3c613 commit d767919Copy full SHA for d767919
src/lib.rs
@@ -656,6 +656,25 @@ where
656
}
657
658
/// Inserts if `cond` holds, else removes
659
+ ///
660
+ /// ```
661
+ /// # use enumflags2::bitflags;
662
+ /// #[derive(Clone, Copy, PartialEq, Debug)]
663
+ /// #[bitflags]
664
+ /// #[repr(u8)]
665
+ /// enum MyFlag {
666
+ /// A = 1 << 0,
667
+ /// B = 1 << 1,
668
+ /// C = 1 << 2,
669
+ /// }
670
671
+ /// let mut state = MyFlag::A | MyFlag::C;
672
+ /// state.set(MyFlag::A | MyFlag::B, 3 > 5);
673
674
+ /// // Because the condition was false, both
675
+ /// // `A` and `B` are removed from the set
676
+ /// assert_eq!(state, MyFlag::C);
677
678
#[inline(always)]
679
pub fn set<B: Into<BitFlags<T>>>(&mut self, other: B, cond: bool) {
680
if cond {
0 commit comments