Skip to main content

BitFlag

Struct BitFlag 

Source
pub struct BitFlag<T, U>(/* private fields */)
where
    U: ?Sized;
Expand description

A single named or indexed bit in a BitFlags set.

A BitFlag stores a bit index and is tied to the same storage type T and tag type U as the corresponding BitFlags<T, U>. It is primarily returned by BitFlagsIter and can be combined with other flags or converted into a BitFlags set.

§Formatting

Display writes the flag’s name if one is defined in BitFlagsSpec::FLAG_NAMES, and its mask (1 << bit) in lowercase hexadecimal with a 0x prefix otherwise. The mask is computed from the bit index regardless of whether the index is in range for T.

Debug writes the bit index and the type parameters.

Binary, Octal, LowerHex, and UpperHex write the mask in the corresponding numeric base.

§Method summary

Implementations§

Source§

impl<T, U> BitFlag<T, U>
where U: ?Sized,

Source

pub const fn from_bit_retain(i: u8) -> Self

Creates a bit flag for bit index i.

The index is not checked against the number of bits in T, against BitFlagsSpec::VALID_BITS_MASK, or against BitFlagsSpec::FLAG_NAMES. A BitFlag created with this method may refer to a bit that is out of range for T or invalid for the tag. Use BitFlag::try_from_bit or BitFlag::is_valid when validation is required.

Source

pub const fn bit(&self) -> u8

Returns the zero-based bit index stored in this flag.

Source

pub const fn name(&self) -> Option<&'static str>
where U: BitFlagsSpec<T>,

Returns the primary name of this bit, if one is defined in BitFlagsSpec::FLAG_NAMES.

The primary name is the first entry in the inner slice for this bit. Returns None if the bit has no name.

Source

pub const fn name_and_aliases(&self) -> &'static [&'static str]
where U: BitFlagsSpec<T>,

Returns all names and aliases for this bit.

The returned slice is the entry at this bit’s index in BitFlagsSpec::FLAG_NAMES, or an empty slice if the index is out of range or the bit has no names.

Source

pub fn try_from_str( input: &str, name_matcher: NameMatcher, ) -> Result<Self, BitFlagParseError>
where T: IntOpsExt, U: BitFlagsSpec<T>,

Parses a single flag from input using name_matcher.

This is equivalent to BitFlag::try_from_str, but returns a BitFlagParseError describing the input and expected names on failure.

§Errors

Returns BitFlagParseError if input is neither a recognized named flag nor a hexadecimal flag of the form 0x... with exactly one bit set.

Source

pub fn from_str_opt(input: &str, name_matcher: NameMatcher) -> Option<Self>
where T: IntOpsExt, U: BitFlagsSpec<T>,

Parses a single flag from input using name_matcher.

The input is first matched against the names and aliases in BitFlagsSpec::FLAG_NAMES. If no name matches, it is parsed as a hexadecimal flag with a 0x prefix that must have exactly one bit set.

Returns None if input is not recognized.

Source

pub fn try_from_name( input: &str, name_matcher: NameMatcher, ) -> Result<Self, BitFlagParseNameError>
where T: IntOpsExt, U: BitFlagsSpec<T>,

Parses a named flag from input using name_matcher.

This is equivalent to BitFlag::try_from_name, but returns a BitFlagParseNameError describing the input and expected names on failure.

§Errors

Returns BitFlagParseNameError if input does not match any name or alias in BitFlagsSpec::FLAG_NAMES.

Source

pub fn from_name_opt(input: &str, name_matcher: NameMatcher) -> Option<Self>
where T: IntOpsExt, U: BitFlagsSpec<T>,

Parses a named flag from input using name_matcher.

The input is matched against all names and aliases in BitFlagsSpec::FLAG_NAMES. Returns None if no name matches.

Source

pub fn try_from_hex(input: &str) -> Result<Self, BitFlagParseHexError>
where T: IntOpsExt,

Parses a hexadecimal flag from input.

This is equivalent to BitFlag::try_from_hex, but returns a BitFlagParseHexError describing the input on failure.

§Errors

Returns BitFlagParseHexError if input is not a valid 0x-prefixed hexadecimal flag with exactly one bit set.

Source

pub fn from_hex_opt(input: &str) -> Option<Self>
where T: IntOpsExt,

Parses a hexadecimal flag from input.

The input must have a 0x prefix and represent a value with exactly one bit set. A leading + is not accepted. Returns None if input is not a valid hexadecimal flag.

Source§

impl<U> BitFlag<u8, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<u8, U>) -> Option<Self>
where U: BitFlagsSpec<u8>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<u8>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: u8) -> Option<Self>
where U: BitFlagsSpec<u8>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: u8) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<u8>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<u8>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<u8, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<u8, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<u8, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<u8, U>

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.

Source

pub const fn complement(self) -> BitFlags<u8, U>
where 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> BitFlag<u16, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<u16, U>) -> Option<Self>
where U: BitFlagsSpec<u16>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<u16>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: u16) -> Option<Self>
where U: BitFlagsSpec<u16>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: u16) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<u16>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<u16>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<u16, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<u16, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<u16, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<u16, U>

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.

Source

pub const fn complement(self) -> BitFlags<u16, U>
where 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> BitFlag<u32, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<u32, U>) -> Option<Self>
where U: BitFlagsSpec<u32>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<u32>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: u32) -> Option<Self>
where U: BitFlagsSpec<u32>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: u32) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<u32>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<u32>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<u32, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<u32, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<u32, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<u32, U>

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.

Source

pub const fn complement(self) -> BitFlags<u32, U>
where 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> BitFlag<u64, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<u64, U>) -> Option<Self>
where U: BitFlagsSpec<u64>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<u64>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: u64) -> Option<Self>
where U: BitFlagsSpec<u64>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: u64) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<u64>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<u64>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<u64, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<u64, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<u64, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<u64, U>

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.

Source

pub const fn complement(self) -> BitFlags<u64, U>
where 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> BitFlag<u128, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<u128, U>) -> Option<Self>
where U: BitFlagsSpec<u128>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<u128>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: u128) -> Option<Self>
where U: BitFlagsSpec<u128>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: u128) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<u128>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<u128>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<u128, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<u128, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<u128, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<u128, U>

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.

Source

pub const fn complement(self) -> BitFlags<u128, U>
where 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> BitFlag<usize, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<usize, U>) -> Option<Self>
where U: BitFlagsSpec<usize>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<usize>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: usize) -> Option<Self>
where U: BitFlagsSpec<usize>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: usize) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<usize>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<usize>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<usize, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<usize, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<usize, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<usize, U>

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.

Source

pub const fn complement(self) -> BitFlags<usize, U>
where 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> BitFlag<i8, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<i8, U>) -> Option<Self>
where U: BitFlagsSpec<i8>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<i8>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: i8) -> Option<Self>
where U: BitFlagsSpec<i8>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: i8) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<i8>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<i8>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<i8, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<i8, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<i8, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<i8, U>

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.

Source

pub const fn complement(self) -> BitFlags<i8, U>
where 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> BitFlag<i16, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<i16, U>) -> Option<Self>
where U: BitFlagsSpec<i16>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<i16>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: i16) -> Option<Self>
where U: BitFlagsSpec<i16>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: i16) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<i16>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<i16>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<i16, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<i16, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<i16, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<i16, U>

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.

Source

pub const fn complement(self) -> BitFlags<i16, U>
where 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> BitFlag<i32, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<i32, U>) -> Option<Self>
where U: BitFlagsSpec<i32>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<i32>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: i32) -> Option<Self>
where U: BitFlagsSpec<i32>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: i32) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<i32>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<i32>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<i32, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<i32, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<i32, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<i32, U>

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.

Source

pub const fn complement(self) -> BitFlags<i32, U>
where 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> BitFlag<i64, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<i64, U>) -> Option<Self>
where U: BitFlagsSpec<i64>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<i64>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: i64) -> Option<Self>
where U: BitFlagsSpec<i64>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: i64) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<i64>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<i64>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<i64, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<i64, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<i64, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<i64, U>

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.

Source

pub const fn complement(self) -> BitFlags<i64, U>
where 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> BitFlag<i128, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<i128, U>) -> Option<Self>
where U: BitFlagsSpec<i128>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<i128>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: i128) -> Option<Self>
where U: BitFlagsSpec<i128>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: i128) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<i128>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<i128>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<i128, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<i128, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<i128, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<i128, U>

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.

Source

pub const fn complement(self) -> BitFlags<i128, U>
where 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> BitFlag<isize, U>
where U: ?Sized,

Source

pub const fn try_from_flags(flags: BitFlags<isize, U>) -> Option<Self>
where U: BitFlagsSpec<isize>,

Creates a bit flag from a BitFlags set.

Returns Some if flags contains exactly one set bit and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if flags is empty, has more than one bit set, or the single set bit is not valid.

This is equivalent to BitFlag::try_from_bits on flags.bits().

Source

pub const fn try_from_bit(i: u8) -> Option<Self>
where U: BitFlagsSpec<isize>,

Creates a validated bit flag for bit index i.

Returns None if i is not set in BitFlagsSpec::VALID_BITS_MASK.

The index i must be less than the number of bits in the storage type.

Source

pub const fn try_from_bits(bits: isize) -> Option<Self>
where U: BitFlagsSpec<isize>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is zero, has more than one bit set, or the single set bit is not valid.

Source

pub const fn try_from_bits_retain(bits: isize) -> Option<Self>

Creates a single-bit flag from bits if exactly one bit is set.

The single set bit is not checked against BitFlagsSpec::VALID_BITS_MASK.

Returns None if bits is 0 or has more than one bit set.

Source

pub const fn is_valid(&self) -> bool
where U: BitFlagsSpec<isize>,

Returns true if this flag refers to a valid bit.

A flag is valid when its bit index is within the width of T and the corresponding bit is present in BitFlagsSpec::VALID_BITS_MASK.

BitFlag::from_bit_retain does not validate the bit index, so a BitFlag constructed through it may be invalid.

Source

pub const fn mask(&self) -> Option<isize>

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T.

The mask is 1 << bit. It is not checked against BitFlagsSpec::VALID_BITS_MASK; use BitFlag::is_valid when tag validity is required.

Source

pub const fn intersection(self, other: Self) -> BitFlags<isize, U>

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.

Source

pub const fn union(self, other: Self) -> BitFlags<isize, U>

Returns the union of self and other.

This is a raw-bit operation. Invalid bits in either operand are preserved.

Source

pub const fn difference(self, other: Self) -> BitFlags<isize, U>

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.

Source

pub const fn symmetric_difference(self, other: Self) -> BitFlags<isize, U>

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.

Source

pub const fn complement(self) -> BitFlags<isize, U>
where 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 BitFlag<T, U>
where U: ?Sized,

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<T, U> Binary for BitFlag<T, U>
where U: ?Sized,

Formats this flag’s mask (1 << bit) in binary.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> BitAnd for BitFlag<T, U>
where T: BitAnd<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, U> BitAnd<BitFlag<T, U>> for BitFlags<T, U>
where T: BitAnd<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitFlag<T, U>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, U> BitAnd<BitFlags<T, U>> for BitFlag<T, U>
where T: BitAnd<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitFlags<T, U>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, U> BitAndAssign<BitFlag<T, U>> for BitFlags<T, U>
where T: BitAndAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn bitand_assign(&mut self, rhs: BitFlag<T, U>)

Performs the &= operation. Read more
Source§

impl<T, U> BitFlagExt<T, U> for BitFlag<T, U>
where U: ?Sized,

Source§

fn try_from_flags(flags: BitFlags<T, U>) -> Option<Self>
where T: Copy + PartialEq + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

Creates a bit flag from a BitFlags set. Read more
Source§

fn try_from_bit(i: u8) -> Option<Self>
where T: PartialEq + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

Creates a validated bit flag for bit index i. Read more
Source§

fn try_from_bits(bits: T) -> Option<Self>
where T: PartialEq + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

Creates a validated bit flag from bits if exactly one bit is set and that bit is valid according to BitFlagsSpec::VALID_BITS_MASK. Read more
Source§

fn try_from_bits_retain(bits: T) -> Option<Self>
where T: IntOpsExt,

Creates a single-bit flag from bits if exactly one bit is set. Read more
Source§

fn is_valid(&self) -> bool
where T: Copy + PartialEq + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

Returns true if this flag refers to a valid bit. Read more
Source§

fn mask(&self) -> Option<T>
where T: IntOpsExt,

Returns the single-bit mask for this flag, or None if the bit index is outside the width of T. Read more
Source§

fn intersection(self, other: Self) -> BitFlags<T, U>
where T: Copy + BitAnd<T, Output = T> + IntOpsExt,

Returns the intersection of self and other. Read more
Source§

fn union(self, other: Self) -> BitFlags<T, U>
where T: Copy + BitOr<T, Output = T> + IntOpsExt,

Returns the union of self and other. Read more
Source§

fn difference(self, other: Self) -> BitFlags<T, U>
where T: Copy + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt,

Returns the difference of self and other. Read more
Source§

fn symmetric_difference(self, other: Self) -> BitFlags<T, U>
where T: Copy + BitXor<T, Output = T> + IntOpsExt,

Returns the symmetric difference of self and other. Read more
Source§

fn complement(self) -> BitFlags<T, U>
where T: Copy + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

Returns the complement of self. Read more
Source§

impl<T, U> BitOr for BitFlag<T, U>
where T: BitOr<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<T, U> BitOr<BitFlag<T, U>> for BitFlags<T, U>
where T: BitOr<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitFlag<T, U>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T, U> BitOr<BitFlags<T, U>> for BitFlag<T, U>
where T: BitOr<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitFlags<T, U>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T, U> BitOrAssign<BitFlag<T, U>> for BitFlags<T, U>
where T: BitOrAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn bitor_assign(&mut self, rhs: BitFlag<T, U>)

Performs the |= operation. Read more
Source§

impl<T, U> BitXor for BitFlag<T, U>
where T: BitXor<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, U> BitXor<BitFlag<T, U>> for BitFlags<T, U>
where T: BitXor<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitFlag<T, U>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, U> BitXor<BitFlags<T, U>> for BitFlag<T, U>
where T: BitXor<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitFlags<T, U>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, U> BitXorAssign<BitFlag<T, U>> for BitFlags<T, U>
where T: BitXorAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn bitxor_assign(&mut self, rhs: BitFlag<T, U>)

Performs the ^= operation. Read more
Source§

impl<T, U> Clone for BitFlag<T, U>
where U: ?Sized,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, U> Copy for BitFlag<T, U>
where U: ?Sized,

Source§

impl<T, U> Debug for BitFlag<T, U>
where U: ?Sized,

Formats this flag’s bit index and type parameters.

Use Display to format the flag’s mask or name instead.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T, U> Deserialize<'de> for BitFlag<T, U>
where T: IntOpsExt, U: ?Sized + BitFlagsSpec<T>,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, U> Display for BitFlag<T, U>
where U: ?Sized + BitFlagsSpec<T>,

Formats this flag as its name if one is defined for its bit, or as its mask (1 << bit) in lowercase hexadecimal with a 0x prefix otherwise.

The mask is computed from the bit index regardless of whether the index is in range for T. See BitFlag::is_valid.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Eq for BitFlag<T, U>
where U: ?Sized,

Source§

impl<T, U> Extend<BitFlag<T, U>> for BitFlags<T, U>
where T: BitOrAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = BitFlag<T, U>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, U> From<BitFlag<T, U>> for BitFlags<T, U>
where T: IntOpsExt, U: ?Sized,

Source§

fn from(flag: BitFlag<T, U>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> FromIterator<BitFlag<T, U>> for BitFlags<T, U>
where T: BitOrAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = BitFlag<T, U>>,

Creates a value from an iterator. Read more
Source§

impl<T, U> FromStr for BitFlag<T, U>
where T: IntOpsExt, U: ?Sized + BitFlagsSpec<T>,

Source§

type Err = BitFlagParseError

The associated error which can be returned from parsing.
Source§

fn from_str(input: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T, U> Hash for BitFlag<T, U>
where U: ?Sized,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, U> LowerHex for BitFlag<T, U>
where U: ?Sized,

Formats this flag’s mask (1 << bit) in lowercase hexadecimal.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Not for BitFlag<T, U>
where T: Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: ?Sized + BitFlagsSpec<T>,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T, U> Octal for BitFlag<T, U>
where U: ?Sized,

Formats this flag’s mask (1 << bit) in octal.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Ord for BitFlag<T, U>
where U: ?Sized,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<T, U> PartialEq for BitFlag<T, U>
where U: ?Sized,

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, U> PartialEq<BitFlag<T, U>> for BitFlags<T, U>
where T: Copy + PartialEq + IntOpsExt, U: ?Sized,

Source§

fn eq(&self, other: &BitFlag<T, U>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, U> PartialEq<BitFlags<T, U>> for BitFlag<T, U>
where T: Copy + PartialEq + IntOpsExt, U: ?Sized,

Source§

fn eq(&self, other: &BitFlags<T, U>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, U> PartialOrd for BitFlag<T, U>
where U: ?Sized,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, U> PartialOrd<BitFlag<T, U>> for BitFlags<T, U>
where T: Copy + PartialOrd + IntOpsExt, U: ?Sized,

Source§

fn partial_cmp(&self, other: &BitFlag<T, U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, U> PartialOrd<BitFlags<T, U>> for BitFlag<T, U>
where T: Copy + PartialOrd + IntOpsExt, U: ?Sized,

Source§

fn partial_cmp(&self, other: &BitFlags<T, U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, U> Pod for BitFlag<T, U>
where T: 'static, U: 'static + ?Sized,

Available on crate feature bytemuck only.
Source§

impl<T, U> Serialize for BitFlag<T, U>
where U: ?Sized + BitFlagsSpec<T>,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T, U> Sub<BitFlag<T, U>> for BitFlags<T, U>
where T: Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitFlag<T, U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, U> Sub<BitFlags<T, U>> for BitFlag<T, U>
where T: Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: ?Sized,

Source§

type Output = BitFlags<T, U>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BitFlags<T, U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, U> SubAssign<BitFlag<T, U>> for BitFlags<T, U>
where T: Not<Output = T> + BitAndAssign<T> + IntOpsExt, U: ?Sized,

Source§

fn sub_assign(&mut self, rhs: BitFlag<T, U>)

Performs the -= operation. Read more
Source§

impl<T, U> TryFrom<BitFlags<T, U>> for BitFlag<T, U>
where T: Copy + PartialEq + Not<Output = T> + BitAnd<T, Output = T> + IntOpsExt, U: BitFlagsSpec<T>,

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.

Source§

type Error = BitFlagFromFlagsError

The type returned in the event of a conversion error.
Source§

fn try_from(flags: BitFlags<T, U>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T, U> UpperHex for BitFlag<T, U>
where U: ?Sized,

Formats this flag’s mask (1 << bit) in uppercase hexadecimal.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Zeroable for BitFlag<T, U>
where U: ?Sized,

Available on crate feature bytemuck only.
Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl<T, U> Freeze for BitFlag<T, U>
where PhantomData<fn() -> T>: Freeze, PhantomData<fn() -> *const U>: Freeze, U: ?Sized,

§

impl<T, U> RefUnwindSafe for BitFlag<T, U>

§

impl<T, U> Send for BitFlag<T, U>
where PhantomData<fn() -> T>: Send, PhantomData<fn() -> *const U>: Send, U: ?Sized,

§

impl<T, U> Sync for BitFlag<T, U>
where PhantomData<fn() -> T>: Sync, PhantomData<fn() -> *const U>: Sync, U: ?Sized,

§

impl<T, U> Unpin for BitFlag<T, U>
where PhantomData<fn() -> T>: Unpin, PhantomData<fn() -> *const U>: Unpin, U: ?Sized,

§

impl<T, U> UnsafeUnpin for BitFlag<T, U>

§

impl<T, U> UnwindSafe for BitFlag<T, U>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.