Lines Matching refs:bits
28 //! const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
62 //! self.bits = 0; // The `bits` field can be accessed from within the
146 //! implemented by displaying the bits value of the internal struct.
164 //! - `bits`: the raw value of the flags currently stored
166 //! representation contains bits that do not correspond to a
169 //! any bits that do not correspond to defined flags
171 //! all bits (even those not corresponding to defined
206 //! // Results in default value with bits: 0
217 //! assert_eq!(derived_default.bits(), 0);
298 /// const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
329 /// self.bits = 0; // The `bits` field can be accessed from within the
365 bits: $T,
409 const $Flag: $T = Self::$Flag.bits;
413 Self { bits: $(<Self as __BitFlags>::$Flag)|+ }
418 Self { bits: 0 }
461 if Self::$Flag.bits == 0 && self.bits != 0 {
464 self.bits & Self::$Flag.bits == Self::$Flag.bits
481 let extra_bits = self.bits & !Self::all().bits();
498 $crate::_core::fmt::Binary::fmt(&self.bits, f)
503 $crate::_core::fmt::Octal::fmt(&self.bits, f)
508 $crate::_core::fmt::LowerHex::fmt(&self.bits, f)
513 $crate::_core::fmt::UpperHex::fmt(&self.bits, f)
521 pub const $Flag: Self = Self { bits: $value };
527 Self { bits: 0 }
545 pub const fn bits(&self) -> $T {
546 self.bits
550 /// representation contains bits that do not correspond to a flag.
552 pub const fn from_bits(bits: $T) -> $crate::_core::option::Option<Self> {
553 if (bits & !Self::all().bits()) == 0 {
554 $crate::_core::option::Option::Some(Self { bits })
560 /// Convert from underlying bit representation, dropping any bits
563 pub const fn from_bits_truncate(bits: $T) -> Self {
564 Self { bits: bits & Self::all().bits }
568 /// bits (even those not corresponding to a defined flag).
573 /// disallow extra bits for their bitflags type.
576 /// all bits correspond to a defined flag or that extra bits
579 pub const unsafe fn from_bits_unchecked(bits: $T) -> Self {
580 Self { bits }
586 self.bits() == Self::empty().bits()
592 Self::all().bits | self.bits == self.bits
598 !(Self { bits: self.bits & other.bits}).is_empty()
604 (self.bits & other.bits) == other.bits
610 self.bits |= other.bits;
616 self.bits &= !other.bits;
622 self.bits ^= other.bits;
648 Self { bits: self.bits & other.bits }
665 Self { bits: self.bits | other.bits }
683 Self { bits: self.bits & !other.bits }
702 Self { bits: self.bits ^ other.bits }
721 Self::from_bits_truncate(!self.bits)
732 Self { bits: self.bits | other.bits }
740 self.bits |= other.bits;
750 Self { bits: self.bits ^ other.bits }
758 self.bits ^= other.bits;
768 Self { bits: self.bits & other.bits }
776 self.bits &= other.bits;
786 Self { bits: self.bits & !other.bits }
794 self.bits &= !other.bits;
804 Self { bits: !self.bits } & Self::all()
956 const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
965 const _CFG_C = Self::_CFG_A.bits | 0b10;
984 assert_eq!(Flags::empty().bits(), 0b00000000);
985 assert_eq!(Flags::A.bits(), 0b00000001);
986 assert_eq!(Flags::ABC.bits(), 0b00000111);
988 assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
989 assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8);
991 assert_eq!(EmptyFlags::empty().bits(), 0b00000000);
1191 assert_eq!(ab.bits, 0b011);
1192 assert_eq!(bc.bits, 0b110);
1193 assert_eq!(ac.bits, 0b101);
1246 assert_eq!(e1.bits, 0b1101);
1278 || (0..=0b111_1111_1111).map(|bits| unsafe { Test::from_bits_unchecked(bits) });
1283 Test::from_bits_truncate(!a.bits),
1292 a.union(b).bits,
1293 a.bits | b.bits,
1299 a.intersection(b).bits,
1300 a.bits & b.bits,
1306 a.symmetric_difference(b).bits,
1307 a.bits ^ b.bits,
1313 a.difference(b).bits,
1314 a.bits & !b.bits,
1321 b.difference(a).bits,
1322 b.bits & !a.bits,
1614 assert_eq!(module::Test::FOO.bits(), 1);
1634 super::submodule::Test::FOO.bits()
1675 const ABC = Self::A.bits | Self::B.bits | Self::C.bits;
1680 assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001);
1681 assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000);
1682 assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000);
1684 Flags128::ABC.bits,
1699 assert_eq!(serialized, r#"{"bits":3}"#);
1704 let deserialized: SerdeFlags = serde_json::from_str(r#"{"bits":12}"#).unwrap();
1708 assert_eq!(deserialized.bits, expected.bits);
1717 assert_eq!(deserialized.bits, flags.bits);