pub struct ExampleFlags(/* private fields */)
where
u32: BitsPrimitive;
Expand description
A example bitflag
Implementations§
Source§impl ExampleFlags
impl ExampleFlags
pub const Flag1: Self
pub const Flag2: Self
pub const Flag3: Self
pub const Flag4: Self
pub const Flag5: Self
pub const Flag6: Self
pub const Flag7: Self
pub const Flag8: Self
pub const Flag9: Self
pub const Flag10: Self
pub const Flag11: Self
pub const Flag12: Self
Source§impl ExampleFlags
impl ExampleFlags
Sourcepub const fn from_bits(bits: u32) -> Option<Self>
pub const fn from_bits(bits: u32) -> Option<Self>
Converts from a bits
value. Returning None
is any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: u32) -> Self
pub const fn from_bits_truncate(bits: u32) -> Self
Convert from bits
value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u32) -> Self
pub const fn from_bits_retain(bits: u32) -> Self
Convert from bits
value exactly.
Sourcepub fn from_flag_name(name: &str) -> Option<Self>
pub fn from_flag_name(name: &str) -> Option<Self>
Convert from a flag name
.
Sourcepub const fn all_bits() -> Self
pub const fn all_bits() -> Self
Returns a flag value that contains all value.
This will include bits that do not have any flags/meaning.
Use all
if you want only the specified flags set.
Sourcepub const fn is_all_bits(&self) -> bool
pub const fn is_all_bits(&self) -> bool
Returns true
if the flag value contains all value bits set.
This will check for all bits.
Use is_all
if you want to check for all specified flags.
Sourcepub const fn all() -> Self
pub const fn all() -> Self
Construct a flag value with all known flags set.
This will only set the flags specified as associated constant.
Sourcepub const fn contains_unknown_bits(&self) -> bool
pub const fn contains_unknown_bits(&self) -> bool
Returns true
if there are any unknown bits set in the flag value.
Sourcepub const fn truncated(&self) -> Self
pub const fn truncated(&self) -> Self
Returns a bit flag that only has bits corresponding to the specified flags as associated constant.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true
if this flag value intersects with any value in other
.
This is equivalent to (self & other) != Self::empty()
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true
if this flag value contains all values of other
.
This is equivalent to (self & other) == other
Sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Returns the bitwise NOT of the flag.
This function does not truncate unused bits (bits that do not have any flags/meaning).
Use complement
if you want that the result to be truncated in one call.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection from this value with other
.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns the difference from this value with other
.
In other words, returns the intersection of this value with the negation of other
.
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference from this value with other
.
Sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
Returns the complement of the value.
This is very similar to the not
, but truncates non used bits.
Source§impl ExampleFlags
impl ExampleFlags
Sourcepub const fn iter(&self) -> Iter<Self> ⓘ
pub const fn iter(&self) -> Iter<Self> ⓘ
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<Self> ⓘ
pub const fn iter_names(&self) -> IterNames<Self> ⓘ
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Trait Implementations§
Source§impl Binary for ExampleFlags
impl Binary for ExampleFlags
Source§impl BitAnd for ExampleFlags
impl BitAnd for ExampleFlags
Source§impl BitAndAssign for ExampleFlags
impl BitAndAssign for ExampleFlags
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moreSource§impl BitOr for ExampleFlags
impl BitOr for ExampleFlags
Source§impl BitOrAssign for ExampleFlags
impl BitOrAssign for ExampleFlags
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moreSource§impl BitXor for ExampleFlags
impl BitXor for ExampleFlags
Source§impl BitXorAssign for ExampleFlags
impl BitXorAssign for ExampleFlags
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moreSource§impl Clone for ExampleFlagswhere
u32: BitsPrimitive,
impl Clone for ExampleFlagswhere
u32: BitsPrimitive,
Source§fn clone(&self) -> ExampleFlags
fn clone(&self) -> ExampleFlags
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ExampleFlags
impl Debug for ExampleFlags
Source§impl Extend<ExampleFlags> for ExampleFlags
impl Extend<ExampleFlags> for ExampleFlags
Source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T)
Set all flags of iter
to self
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Flags for ExampleFlags
impl Flags for ExampleFlags
Source§const KNOWN_FLAGS: &'static [(&'static str, ExampleFlags)]
const KNOWN_FLAGS: &'static [(&'static str, ExampleFlags)]
Source§const EXTRA_VALID_BITS: u32 = 4_294_967_295u32
const EXTRA_VALID_BITS: u32 = 4_294_967_295u32
Source§fn from_bits_retain(bits: Self::Bits) -> Self
fn from_bits_retain(bits: Self::Bits) -> Self
bits
value exactly.Source§fn from_bits(bits: Self::Bits) -> Option<Self>
fn from_bits(bits: Self::Bits) -> Option<Self>
bits
value. Returning None
is any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
bits
value, unsetting any unknown bits.Source§fn from_flag_name(name: &str) -> Option<Self>
fn from_flag_name(name: &str) -> Option<Self>
name
.Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn is_all_bits(&self) -> bool
fn is_all_bits(&self) -> bool
true
if the bitflag contains all value bits set. Read moreSource§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true
if there are any unknown bits set in the flag value.Source§fn truncated(&self) -> Self
fn truncated(&self) -> Self
Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
other
.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
other
. Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
other
..Source§fn complement(self) -> Self
fn complement(self) -> Self
Source§impl From<ExampleFlags> for u32
impl From<ExampleFlags> for u32
Source§fn from(val: ExampleFlags) -> Self
fn from(val: ExampleFlags) -> Self
Source§impl From<u32> for ExampleFlags
impl From<u32> for ExampleFlags
Source§impl FromIterator<ExampleFlags> for ExampleFlags
impl FromIterator<ExampleFlags> for ExampleFlags
Source§fn from_iter<T: IntoIterator<Item = Self>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iter: T) -> Self
Create a ExampleFlags
from a iterator of flags.
Source§impl FromStr for ExampleFlags
impl FromStr for ExampleFlags
Source§impl Hash for ExampleFlagswhere
u32: BitsPrimitive,
impl Hash for ExampleFlagswhere
u32: BitsPrimitive,
Source§impl IntoIterator for &ExampleFlags
impl IntoIterator for &ExampleFlags
Source§impl IntoIterator for ExampleFlags
impl IntoIterator for ExampleFlags
Source§impl LowerHex for ExampleFlags
impl LowerHex for ExampleFlags
Source§impl Not for ExampleFlags
impl Not for ExampleFlags
Source§impl Octal for ExampleFlags
impl Octal for ExampleFlags
Source§impl Ord for ExampleFlagswhere
u32: BitsPrimitive,
impl Ord for ExampleFlagswhere
u32: BitsPrimitive,
Source§fn cmp(&self, other: &ExampleFlags) -> Ordering
fn cmp(&self, other: &ExampleFlags) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ExampleFlagswhere
u32: BitsPrimitive,
impl PartialEq for ExampleFlagswhere
u32: BitsPrimitive,
Source§impl PartialOrd for ExampleFlagswhere
u32: BitsPrimitive,
impl PartialOrd for ExampleFlagswhere
u32: BitsPrimitive,
Source§impl Sub for ExampleFlags
impl Sub for ExampleFlags
Source§impl SubAssign for ExampleFlags
impl SubAssign for ExampleFlags
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
The intersection of a source flag with the complement of a target flags value
Source§impl UpperHex for ExampleFlags
impl UpperHex for ExampleFlags
impl Copy for ExampleFlagswhere
u32: BitsPrimitive,
impl Eq for ExampleFlagswhere
u32: BitsPrimitive,
impl StructuralPartialEq for ExampleFlagswhere
u32: BitsPrimitive,
Auto Trait Implementations§
impl Freeze for ExampleFlags
impl RefUnwindSafe for ExampleFlags
impl Send for ExampleFlags
impl Sync for ExampleFlags
impl Unpin for ExampleFlags
impl UnwindSafe for ExampleFlags
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 4 bytes