pub struct Flags(/* private fields */)
where
u32: BitflagPrimitive;
Expand description
Example of the generated code by bitflag macro.
Implementations§
Source§impl Flags
impl Flags
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 bitflag 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 bitflag 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 bitflag with all known flags set.
This will only set the flags specified as associated constant.
Sourcepub const fn truncate(&self) -> Self
pub const fn truncate(&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 bitflag 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 bitflag 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
.
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 Flags
impl Flags
Sourcepub const fn iter(&self) -> FlagsIter ⓘ
pub const fn iter(&self) -> FlagsIter ⓘ
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) -> FlagsIterNames ⓘ
pub const fn iter_names(&self) -> FlagsIterNames ⓘ
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 BitAndAssign for Flags
impl BitAndAssign for Flags
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moreSource§impl BitOrAssign for Flags
impl BitOrAssign for Flags
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moreSource§impl BitXorAssign for Flags
impl BitXorAssign for Flags
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moreSource§impl Extend<Flags> for Flags
impl Extend<Flags> for Flags
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 FromIterator<Flags> for Flags
impl FromIterator<Flags> for Flags
Source§fn from_iter<T: IntoIterator<Item = Self>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iter: T) -> Self
Create a #ty_name
from a iterator of flags.
Source§impl IntoIterator for &Flags
impl IntoIterator for &Flags
Source§impl IntoIterator for Flags
impl IntoIterator for Flags
Source§impl Ord for Flagswhere
u32: BitflagPrimitive,
impl Ord for Flagswhere
u32: BitflagPrimitive,
Source§impl PartialOrd for Flagswhere
u32: BitflagPrimitive,
impl PartialOrd for Flagswhere
u32: BitflagPrimitive,
Source§impl SubAssign for Flags
impl SubAssign for Flags
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