pub struct BitFlags<T, U>(/* private fields */)
where
U: ?Sized;Expand description
A type-safe set of flags stored in an integer T.
The second type parameter U is a tag type that distinguishes flag sets
that share the same storage type.
When U implements BitFlagsSpec, it defines which bits are valid.
BitFlags is #[repr(transparent)] over T, so it has the same layout as
T.
§Invalid bits
A BitFlags value is not guaranteed to contain only valid bits.
BitFlags::from_bits_retain can create a value with any bit pattern of
T, and raw-bit operations such as BitFlags::insert,
BitFlags::toggle, BitFlags::union, and bitwise operators preserve
invalid bits. Use BitFlags::truncate, BitFlags::try_from_bits, or
BitFlags::from_bits_truncate when a value must be restricted to
BitFlagsSpec::VALID_BITS_MASK.
BitFlags::bits returns the raw stored bits, including any invalid bits
that are present.
§Examples
use bitflags_lite::{BitFlags, BitFlagsSpec, NameMatcher};
struct PermissionsTag;
impl BitFlagsSpec<u32> for PermissionsTag {
const VALID_BITS_MASK: u32 = 0b111;
const FLAG_NAMES: &[&[&str]] = &[&["read"], &["write"], &["exec", "execute"]];
const COMBINED_NAMES: &[(u32, &str)] = &[(0, "none"), (0b111, "rwx")];
const DEFAULT_NAME_MATCHER: NameMatcher = NameMatcher::Exact;
}
type Permissions = BitFlags<u32, PermissionsTag>;
const READ: Permissions = Permissions::try_from_bits(1 << 0).unwrap();
const WRITE: Permissions = Permissions::try_from_bits(1 << 1).unwrap();
const EXEC: Permissions = Permissions::try_from_bits(1 << 2).unwrap();
let rw = READ | WRITE;
assert!(rw.contains(READ));
assert!(rw.contains(WRITE));
assert!(!rw.contains(EXEC));§Method summary
empty(): Return a set with no bits set.all_valid(): Return a set with all valid bits set.from_bits_retain(): Convert from raw bits without validation.from_bits_truncate(): Convert from raw bits, clearing invalid bits.try_from_bits(): Convert from raw bits, rejecting invalid bits.from_bit_retain(): Return a set with only the bit at a given index, without validation.from_bit_truncate(): Return a set with only the bit at a given index, clearing it if invalid.try_from_bit(): Return a set with only the bit at a given index, rejecting it if invalid.from_flag(): Convert from a singleBitFlag.try_from_str(): Parse from a separated string.bits(): Return the raw stored bits.bits_mut(): Return a mutable reference to the raw bits.into_bits(): Consume the set and return the raw bits.iter(): Return an iterator over the set bits.is_empty(): Returntrueif no bits are set.is_valid(): Returntrueif all set bits are valid for the tag.intersects(): Returntrueif any bits are shared.contains(): Returntrueif all bits of another set are present.insert(): Add all bits of another set.remove(): Remove all bits of another set.toggle(): Flip all bits of another set.set(): Insert or remove bits based on a boolean.clear(): Remove all bits, valid and invalid.truncate(): Remove all invalid bits.intersection(): Return the bits set in both sets.union(): Return the bits set in either set.difference(): Return the bits set inselfbut not inother.symmetric_difference(): Return the bits set in exactly one set.complement(): Return the valid bits not set inself.
Implementations§
Source§impl<T, U> BitFlags<T, U>where
U: ?Sized,
impl<T, U> BitFlags<T, U>where
U: ?Sized,
Sourcepub const fn empty() -> Selfwhere
T: IntOpsExt,
pub const fn empty() -> Selfwhere
T: IntOpsExt,
Creates a flag set with no bits set (zero bits).
This is equivalent to from_bits_retain(0).
Sourcepub const fn all_valid() -> Selfwhere
T: 'static,
U: BitFlagsSpec<T>,
pub const fn all_valid() -> Selfwhere
T: 'static,
U: BitFlagsSpec<T>,
Creates a flag set containing all valid bits for this tag.
This returns exactly BitFlagsSpec::VALID_BITS_MASK. Invalid bits
are never set.
The method is named all_valid rather than all because a
BitFlags value can contain invalid bits after
BitFlags::from_bits_retain.
In that case, “all” would be ambiguous: all bits of the storage
type, all bits currently set, or all valid bits?
all_valid makes the meaning explicit.
Sourcepub const fn from_bits_retain(bits: T) -> Self
pub const fn from_bits_retain(bits: T) -> Self
Creates a flag set from raw bits without validation.
The resulting value may contain bits not present in
BitFlagsSpec::VALID_BITS_MASK.
Such invalid bits are preserved by this constructor and by
raw-bit operations unless an operation clears them, such as
BitFlags::truncate, BitFlags::complement,
BitFlags::from_bits_truncate, or Not.
Sourcepub const fn bits(&self) -> Twhere
T: Copy,
pub const fn bits(&self) -> Twhere
T: Copy,
Returns the raw bits stored in this flag set.
The returned value may contain invalid bits if this value was
created with BitFlags::from_bits_retain and has not since
been passed through an operation that clears invalid bits, such
as BitFlags::truncate or BitFlags::complement.
Sourcepub const fn bits_mut(&mut self) -> &mut T
pub const fn bits_mut(&mut self) -> &mut T
Returns a mutable reference to the raw bits stored in this flag set.
Mutating the returned value can introduce invalid bits.
Use BitFlags::truncate afterwards if the value must contain only
valid bits.
Sourcepub fn into_bits(self) -> T
pub fn into_bits(self) -> T
Consumes this flag set and returns the raw bits.
This is the consuming counterpart to BitFlags::bits.
Like BitFlags::bits, the returned value may contain bits not present
in BitFlagsSpec::VALID_BITS_MASK.
This method does not require T: Copy, so it is available for storage
types that are not Copy.
Sourcepub const fn iter(self) -> BitFlagsIter<T, U> ⓘ
pub const fn iter(self) -> BitFlagsIter<T, U> ⓘ
Returns an iterator over the individual set bits in this flag set.
The iterator yields BitFlag values from the least significant bit to
the most significant bit.
It includes invalid bits if they are present.
Sourcepub fn try_from_str(
input: &str,
separator: &'static str,
name_matcher: NameMatcher,
) -> Result<Self, BitFlagsParseError>
pub fn try_from_str( input: &str, separator: &'static str, name_matcher: NameMatcher, ) -> Result<Self, BitFlagsParseError>
Parses a flag set from a string.
The input may be empty, which returns BitFlags::empty.
Otherwise it is split on given separator, and each part is trimmed and
matched against the names in BitFlagsSpec::FLAG_NAMES.
Match behavior is specified by name_matcher.
A part may also be a hexadecimal flag with a 0x prefix.
This method does not validate or truncate the parsed bits against
BitFlagsSpec::VALID_BITS_MASK.
The returned value may contain invalid bits.
Note that if separator is an empty string, the method would split into
individual characters, which is almost certainly not intended.
§Errors
Returns BitFlagsParseError if input is not a separator-separated
list of named flags or hexadecimal flags.
Source§impl<U> BitFlags<u8, U>where
U: ?Sized,
impl<U> BitFlags<u8, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<u8, U>) -> Self
pub const fn from_flag(flag: BitFlag<u8, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u8>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u8>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u8>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u8>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: u8) -> Option<Self>where
U: BitFlagsSpec<u8>,
pub const fn try_from_bits(bits: u8) -> Option<Self>where
U: BitFlagsSpec<u8>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: u8) -> Selfwhere
U: BitFlagsSpec<u8>,
pub const fn from_bits_truncate(bits: u8) -> Selfwhere
U: BitFlagsSpec<u8>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u8>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u8>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<u8>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<u8>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u8>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u8>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<u16, U>where
U: ?Sized,
impl<U> BitFlags<u16, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<u16, U>) -> Self
pub const fn from_flag(flag: BitFlag<u16, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u16>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u16>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u16>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u16>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: u16) -> Option<Self>where
U: BitFlagsSpec<u16>,
pub const fn try_from_bits(bits: u16) -> Option<Self>where
U: BitFlagsSpec<u16>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: u16) -> Selfwhere
U: BitFlagsSpec<u16>,
pub const fn from_bits_truncate(bits: u16) -> Selfwhere
U: BitFlagsSpec<u16>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u16>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u16>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<u16>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<u16>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u16>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u16>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<u32, U>where
U: ?Sized,
impl<U> BitFlags<u32, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<u32, U>) -> Self
pub const fn from_flag(flag: BitFlag<u32, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u32>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u32>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u32>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u32>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: u32) -> Option<Self>where
U: BitFlagsSpec<u32>,
pub const fn try_from_bits(bits: u32) -> Option<Self>where
U: BitFlagsSpec<u32>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: u32) -> Selfwhere
U: BitFlagsSpec<u32>,
pub const fn from_bits_truncate(bits: u32) -> Selfwhere
U: BitFlagsSpec<u32>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u32>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u32>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<u32>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<u32>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u32>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u32>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<u64, U>where
U: ?Sized,
impl<U> BitFlags<u64, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<u64, U>) -> Self
pub const fn from_flag(flag: BitFlag<u64, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u64>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u64>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u64>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u64>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: u64) -> Option<Self>where
U: BitFlagsSpec<u64>,
pub const fn try_from_bits(bits: u64) -> Option<Self>where
U: BitFlagsSpec<u64>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: u64) -> Selfwhere
U: BitFlagsSpec<u64>,
pub const fn from_bits_truncate(bits: u64) -> Selfwhere
U: BitFlagsSpec<u64>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u64>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u64>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<u64>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<u64>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u64>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u64>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<u128, U>where
U: ?Sized,
impl<U> BitFlags<u128, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<u128, U>) -> Self
pub const fn from_flag(flag: BitFlag<u128, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u128>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<u128>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u128>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<u128>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: u128) -> Option<Self>where
U: BitFlagsSpec<u128>,
pub const fn try_from_bits(bits: u128) -> Option<Self>where
U: BitFlagsSpec<u128>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: u128) -> Selfwhere
U: BitFlagsSpec<u128>,
pub const fn from_bits_truncate(bits: u128) -> Selfwhere
U: BitFlagsSpec<u128>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u128>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<u128>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<u128>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<u128>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u128>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<u128>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<usize, U>where
U: ?Sized,
impl<U> BitFlags<usize, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<usize, U>) -> Self
pub const fn from_flag(flag: BitFlag<usize, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<usize>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<usize>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<usize>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<usize>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: usize) -> Option<Self>where
U: BitFlagsSpec<usize>,
pub const fn try_from_bits(bits: usize) -> Option<Self>where
U: BitFlagsSpec<usize>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: usize) -> Selfwhere
U: BitFlagsSpec<usize>,
pub const fn from_bits_truncate(bits: usize) -> Selfwhere
U: BitFlagsSpec<usize>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<usize>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<usize>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<usize>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<usize>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<usize>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<usize>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<i8, U>where
U: ?Sized,
impl<U> BitFlags<i8, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<i8, U>) -> Self
pub const fn from_flag(flag: BitFlag<i8, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i8>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i8>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i8>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i8>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: i8) -> Option<Self>where
U: BitFlagsSpec<i8>,
pub const fn try_from_bits(bits: i8) -> Option<Self>where
U: BitFlagsSpec<i8>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: i8) -> Selfwhere
U: BitFlagsSpec<i8>,
pub const fn from_bits_truncate(bits: i8) -> Selfwhere
U: BitFlagsSpec<i8>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i8>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i8>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<i8>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<i8>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i8>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i8>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<i16, U>where
U: ?Sized,
impl<U> BitFlags<i16, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<i16, U>) -> Self
pub const fn from_flag(flag: BitFlag<i16, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i16>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i16>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i16>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i16>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: i16) -> Option<Self>where
U: BitFlagsSpec<i16>,
pub const fn try_from_bits(bits: i16) -> Option<Self>where
U: BitFlagsSpec<i16>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: i16) -> Selfwhere
U: BitFlagsSpec<i16>,
pub const fn from_bits_truncate(bits: i16) -> Selfwhere
U: BitFlagsSpec<i16>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i16>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i16>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<i16>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<i16>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i16>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i16>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<i32, U>where
U: ?Sized,
impl<U> BitFlags<i32, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<i32, U>) -> Self
pub const fn from_flag(flag: BitFlag<i32, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i32>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i32>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i32>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i32>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: i32) -> Option<Self>where
U: BitFlagsSpec<i32>,
pub const fn try_from_bits(bits: i32) -> Option<Self>where
U: BitFlagsSpec<i32>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: i32) -> Selfwhere
U: BitFlagsSpec<i32>,
pub const fn from_bits_truncate(bits: i32) -> Selfwhere
U: BitFlagsSpec<i32>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i32>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i32>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<i32>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<i32>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i32>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i32>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<i64, U>where
U: ?Sized,
impl<U> BitFlags<i64, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<i64, U>) -> Self
pub const fn from_flag(flag: BitFlag<i64, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i64>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i64>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i64>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i64>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: i64) -> Option<Self>where
U: BitFlagsSpec<i64>,
pub const fn try_from_bits(bits: i64) -> Option<Self>where
U: BitFlagsSpec<i64>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: i64) -> Selfwhere
U: BitFlagsSpec<i64>,
pub const fn from_bits_truncate(bits: i64) -> Selfwhere
U: BitFlagsSpec<i64>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i64>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i64>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<i64>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<i64>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i64>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i64>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<i128, U>where
U: ?Sized,
impl<U> BitFlags<i128, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<i128, U>) -> Self
pub const fn from_flag(flag: BitFlag<i128, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i128>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<i128>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i128>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<i128>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: i128) -> Option<Self>where
U: BitFlagsSpec<i128>,
pub const fn try_from_bits(bits: i128) -> Option<Self>where
U: BitFlagsSpec<i128>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: i128) -> Selfwhere
U: BitFlagsSpec<i128>,
pub const fn from_bits_truncate(bits: i128) -> Selfwhere
U: BitFlagsSpec<i128>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i128>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<i128>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<i128>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<i128>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i128>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<i128>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Source§impl<U> BitFlags<isize, U>where
U: ?Sized,
impl<U> BitFlags<isize, U>where
U: ?Sized,
Sourcepub const fn from_flag(flag: BitFlag<isize, U>) -> Self
pub const fn from_flag(flag: BitFlag<isize, U>) -> Self
Creates a flag set from a single BitFlag.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
If the flag’s index is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_retain(bit: u8) -> Self
pub const fn from_bit_retain(bit: u8) -> Self
Creates a flag set with only the bit at index bit set.
The bit index is not validated against
BitFlagsSpec::VALID_BITS_MASK.
The resulting value may contain an invalid bit.
Use BitFlags::try_from_bit or
BitFlags::from_bits_truncate when validation or truncation
is required.
If bit is outside the width of T, the result is
BitFlags::empty.
Sourcepub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<isize>,
pub const fn from_bit_truncate(bit: u8) -> Selfwhere
U: BitFlagsSpec<isize>,
Creates a flag set with only the bit at index bit set,
clearing the bit if it is not valid for the tag.
This is the bit-index counterpart to
BitFlags::from_bits_truncate.
If bit is outside the width of T, or if the corresponding
bit is not present in BitFlagsSpec::VALID_BITS_MASK, the
result is BitFlags::empty.
The result always contains either exactly one bit or no bits.
Use BitFlags::try_from_bit when the caller needs to
distinguish a valid index from an invalid one.
Sourcepub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<isize>,
pub const fn try_from_bit(bit: u8) -> Option<Self>where
U: BitFlagsSpec<isize>,
Creates a flag set from bit index bit if that bit is valid.
Returns None if bit is outside the width of T or if the
resulting bit is not present in
BitFlagsSpec::VALID_BITS_MASK.
Sourcepub const fn try_from_bits(bits: isize) -> Option<Self>where
U: BitFlagsSpec<isize>,
pub const fn try_from_bits(bits: isize) -> Option<Self>where
U: BitFlagsSpec<isize>,
Creates a flag set from raw bits if all set bits are valid.
Returns None if bits contains any bit not present in
BitFlagsSpec::VALID_BITS_MASK.
Use BitFlags::from_bits_retain to keep invalid bits, or
BitFlags::from_bits_truncate to clear them.
Sourcepub const fn from_bits_truncate(bits: isize) -> Selfwhere
U: BitFlagsSpec<isize>,
pub const fn from_bits_truncate(bits: isize) -> Selfwhere
U: BitFlagsSpec<isize>,
Creates a flag set from raw bits, clearing any bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This always succeeds and never stores invalid bits.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if no bits are set.
This checks the raw stored bits. A value containing only invalid bits is not empty.
Sourcepub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<isize>,
pub const fn is_valid(&self) -> boolwhere
U: BitFlagsSpec<isize>,
Returns true if all set bits in self are valid for this tag.
A BitFlags value can contain bits not present in
BitFlagsSpec::VALID_BITS_MASK after construction with
BitFlags::from_bits_retain or after raw-bit operations such as
BitFlags::insert, BitFlags::toggle, and BitFlags::union.
This method returns false for such values.
Use BitFlags::truncate or BitFlags::from_bits_truncate to
restrict a value to its valid bits.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self and other have at least one set bit in
common.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if all bits set in other are also set in self.
This compares raw bits. Invalid bits participate in the comparison if they are present.
Sourcepub const fn insert(&mut self, other: Self)
pub const fn insert(&mut self, other: Self)
Inserts all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Inserting other can introduce invalid bits into self.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Removes all bits from self, including any invalid bits.
This is equivalent to assigning BitFlags::empty to self.
Sourcepub const fn truncate(&mut self)where
U: BitFlagsSpec<isize>,
pub const fn truncate(&mut self)where
U: BitFlagsSpec<isize>,
Clears all bits not present in
BitFlagsSpec::VALID_BITS_MASK.
This leaves self unchanged if it already contains only valid
bits.
Sourcepub const fn remove(&mut self, other: Self)
pub const fn remove(&mut self, other: Self)
Removes all bits from other.
This is a raw-bit operation. It cannot introduce new bits, but it does not clear any other invalid bits that may already be present.
Sourcepub const fn toggle(&mut self, other: Self)
pub const fn toggle(&mut self, other: Self)
Toggles all bits from other.
This is a raw-bit operation.
It does not validate or clear invalid bits.
Toggling other can introduce invalid bits into self.
Sourcepub const fn set(&mut self, other: Self, value: bool)
pub const fn set(&mut self, other: Self, value: bool)
Inserts other if value is true, or removes other if
value is false.
This is a raw-bit operation and follows the same invalid-bit
behavior as BitFlags::insert and BitFlags::remove.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved when they are set in both operands.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Returns the union of self and other.
This is a raw-bit operation. Invalid bits in either operand are preserved.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference of self and other.
The result contains bits that are set in self but not in
other.
This is a raw-bit operation.
Invalid bits already present in self are preserved unless they
are also set in other.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference of self and other.
The result contains bits that are set in exactly one of self
or other.
This is a raw-bit operation.
Invalid bits participate and may be preserved.
Sourcepub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<isize>,
pub const fn complement(self) -> Selfwhere
U: BitFlagsSpec<isize>,
Returns the complement of self.
All valid bits not set in self become set, and all invalid
bits become unset.
The result always contains only valid bits.
Trait Implementations§
Source§impl<'a, T, U> Arbitrary<'a> for BitFlags<T, U>
Available on crate feature arbitrary only.
impl<'a, T, U> Arbitrary<'a> for BitFlags<T, U>
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<T, U> BitAndAssign for BitFlags<T, U>where
T: BitAndAssign<T>,
U: ?Sized,
impl<T, U> BitAndAssign for BitFlags<T, U>where
T: BitAndAssign<T>,
U: ?Sized,
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<T, U> BitAndAssign<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> BitAndAssign<BitFlag<T, U>> for BitFlags<T, U>
Source§fn bitand_assign(&mut self, rhs: BitFlag<T, U>)
fn bitand_assign(&mut self, rhs: BitFlag<T, U>)
&= operation. Read moreSource§impl<T, U> BitFlagsExt<T, U> for BitFlags<T, U>where
U: ?Sized,
impl<T, U> BitFlagsExt<T, U> for BitFlags<T, U>where
U: ?Sized,
Source§fn from_bit_retain(bit: u8) -> Selfwhere
T: IntOpsExt,
fn from_bit_retain(bit: u8) -> Selfwhere
T: IntOpsExt,
bit set. Read moreSource§fn from_bit_truncate(bit: u8) -> Self
fn from_bit_truncate(bit: u8) -> Self
bit set, clearing the
bit if it is not valid for the tag. Read moreSource§fn try_from_bit(bit: u8) -> Option<Self>
fn try_from_bit(bit: u8) -> Option<Self>
bit if that bit is valid. Read moreSource§fn try_from_bits(bits: T) -> Option<Self>
fn try_from_bits(bits: T) -> Option<Self>
Source§fn from_bits_truncate(bits: T) -> Selfwhere
T: 'static + BitAnd<T, Output = T>,
U: BitFlagsSpec<T>,
fn from_bits_truncate(bits: T) -> Selfwhere
T: 'static + BitAnd<T, Output = T>,
U: BitFlagsSpec<T>,
BitFlagsSpec::VALID_BITS_MASK. Read moreSource§fn intersects(&self, other: Self) -> bool
fn intersects(&self, other: Self) -> bool
Source§fn clear(&mut self)where
T: IntOpsExt,
fn clear(&mut self)where
T: IntOpsExt,
self, including any invalid bits. Read moreSource§fn truncate(&mut self)where
T: 'static + BitAndAssign<T>,
U: BitFlagsSpec<T>,
fn truncate(&mut self)where
T: 'static + BitAndAssign<T>,
U: BitFlagsSpec<T>,
BitFlagsSpec::VALID_BITS_MASK. Read moreSource§fn insert(&mut self, other: Self)where
T: Copy + BitOrAssign<T>,
fn insert(&mut self, other: Self)where
T: Copy + BitOrAssign<T>,
other. Read moreSource§fn toggle(&mut self, other: Self)where
T: Copy + BitXorAssign<T>,
fn toggle(&mut self, other: Self)where
T: Copy + BitXorAssign<T>,
other. Read moreSource§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
Source§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
Source§fn complement(self) -> Self
fn complement(self) -> Self
self. Read moreSource§impl<T, U> BitOrAssign for BitFlags<T, U>where
T: BitOrAssign<T>,
U: ?Sized,
impl<T, U> BitOrAssign for BitFlags<T, U>where
T: BitOrAssign<T>,
U: ?Sized,
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<T, U> BitOrAssign<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> BitOrAssign<BitFlag<T, U>> for BitFlags<T, U>
Source§fn bitor_assign(&mut self, rhs: BitFlag<T, U>)
fn bitor_assign(&mut self, rhs: BitFlag<T, U>)
|= operation. Read moreSource§impl<T, U> BitXorAssign for BitFlags<T, U>where
T: BitXorAssign<T>,
U: ?Sized,
impl<T, U> BitXorAssign for BitFlags<T, U>where
T: BitXorAssign<T>,
U: ?Sized,
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl<T, U> BitXorAssign<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> BitXorAssign<BitFlag<T, U>> for BitFlags<T, U>
Source§fn bitxor_assign(&mut self, rhs: BitFlag<T, U>)
fn bitxor_assign(&mut self, rhs: BitFlag<T, U>)
^= operation. Read moreimpl<T, U> Copy for BitFlags<T, U>
Source§impl<'de, T, U> Deserialize<'de> for BitFlags<T, U>
Available on crate feature serde only.
impl<'de, T, U> Deserialize<'de> for BitFlags<T, U>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl<T, U> Eq for BitFlags<T, U>
Source§impl<T, U> Extend<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> Extend<BitFlag<T, U>> for BitFlags<T, U>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = BitFlag<T, U>>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = BitFlag<T, U>>,
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T, U> Extend<BitFlags<T, U>> for BitFlags<T, U>where
T: BitOrAssign<T>,
U: ?Sized,
impl<T, U> Extend<BitFlags<T, U>> for BitFlags<T, U>where
T: BitOrAssign<T>,
U: ?Sized,
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Self>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Self>,
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T, U> FromIterator<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> FromIterator<BitFlag<T, U>> for BitFlags<T, U>
Source§impl<T, U> FromIterator<BitFlags<T, U>> for BitFlags<T, U>
impl<T, U> FromIterator<BitFlags<T, U>> for BitFlags<T, U>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Source§impl<T, U> IntoIterator for BitFlags<T, U>
impl<T, U> IntoIterator for BitFlags<T, U>
Source§impl<T, U> IntoIterator for &BitFlags<T, U>
impl<T, U> IntoIterator for &BitFlags<T, U>
Source§impl<T, U> IntoIterator for &mut BitFlags<T, U>
impl<T, U> IntoIterator for &mut BitFlags<T, U>
Source§impl<T, U> Ord for BitFlags<T, U>
impl<T, U> Ord for BitFlags<T, U>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T, U> PartialOrd for BitFlags<T, U>where
T: PartialOrd,
U: ?Sized,
impl<T, U> PartialOrd for BitFlags<T, U>where
T: PartialOrd,
U: ?Sized,
Source§impl<T, U> PartialOrd<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> PartialOrd<BitFlag<T, U>> for BitFlags<T, U>
Source§impl<T, U> PartialOrd<BitFlags<T, U>> for BitFlag<T, U>
impl<T, U> PartialOrd<BitFlags<T, U>> for BitFlag<T, U>
impl<T, U> Pod for BitFlags<T, U>
bytemuck only.Source§impl<T, U> SubAssign for BitFlags<T, U>
impl<T, U> SubAssign for BitFlags<T, U>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl<T, U> SubAssign<BitFlag<T, U>> for BitFlags<T, U>
impl<T, U> SubAssign<BitFlag<T, U>> for BitFlags<T, U>
Source§fn sub_assign(&mut self, rhs: BitFlag<T, U>)
fn sub_assign(&mut self, rhs: BitFlag<T, U>)
-= operation. Read moreSource§impl<T, U> TryFrom<BitFlags<T, U>> for BitFlag<T, U>
Converts a flag set into a single-bit flag.
impl<T, U> TryFrom<BitFlags<T, U>> for BitFlag<T, U>
Converts a flag set into a single-bit flag.
This fails unless flags contains exactly one set bit and that bit is
valid for the tag. See BitFlag::try_from_flags.
Auto Trait Implementations§
impl<T, U> Freeze for BitFlags<T, U>
impl<T, U> RefUnwindSafe for BitFlags<T, U>
impl<T, U> Send for BitFlags<T, U>
impl<T, U> Sync for BitFlags<T, U>
impl<T, U> Unpin for BitFlags<T, U>
impl<T, U> UnsafeUnpin for BitFlags<T, U>
impl<T, U> UnwindSafe for BitFlags<T, U>
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.