pub struct SimpleFlag(/* private fields */);
Expand description
A simple bitflag
Implementations§
Source§impl SimpleFlag
impl SimpleFlag
Source§impl SimpleFlag
impl SimpleFlag
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 SimpleFlag
impl SimpleFlag
Sourcepub const fn iter(&self) -> SimpleFlagIter ⓘ
pub const fn iter(&self) -> SimpleFlagIter ⓘ
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) -> SimpleFlagIterNames ⓘ
pub const fn iter_names(&self) -> SimpleFlagIterNames ⓘ
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 SimpleFlag
impl Binary for SimpleFlag
Source§impl BitAnd for SimpleFlag
impl BitAnd for SimpleFlag
Source§impl BitAndAssign for SimpleFlag
impl BitAndAssign for SimpleFlag
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moreSource§impl BitOr for SimpleFlag
impl BitOr for SimpleFlag
Source§impl BitOrAssign for SimpleFlag
impl BitOrAssign for SimpleFlag
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moreSource§impl BitXor for SimpleFlag
impl BitXor for SimpleFlag
Source§impl BitXorAssign for SimpleFlag
impl BitXorAssign for SimpleFlag
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moreSource§impl Clone for SimpleFlag
impl Clone for SimpleFlag
Source§fn clone(&self) -> SimpleFlag
fn clone(&self) -> SimpleFlag
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SimpleFlag
impl Debug for SimpleFlag
Source§impl Extend<SimpleFlag> for SimpleFlag
impl Extend<SimpleFlag> for SimpleFlag
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 From<SimpleFlag> for u32
impl From<SimpleFlag> for u32
Source§fn from(val: SimpleFlag) -> Self
fn from(val: SimpleFlag) -> Self
Source§impl From<u32> for SimpleFlag
impl From<u32> for SimpleFlag
Source§impl FromIterator<SimpleFlag> for SimpleFlag
impl FromIterator<SimpleFlag> for SimpleFlag
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 Hash for SimpleFlag
impl Hash for SimpleFlag
Source§impl IntoIterator for &SimpleFlag
impl IntoIterator for &SimpleFlag
Source§impl IntoIterator for SimpleFlag
impl IntoIterator for SimpleFlag
Source§impl LowerHex for SimpleFlag
impl LowerHex for SimpleFlag
Source§impl Not for SimpleFlag
impl Not for SimpleFlag
Source§impl Octal for SimpleFlag
impl Octal for SimpleFlag
Source§impl Ord for SimpleFlag
impl Ord for SimpleFlag
Source§fn cmp(&self, other: &SimpleFlag) -> Ordering
fn cmp(&self, other: &SimpleFlag) -> 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 SimpleFlag
impl PartialEq for SimpleFlag
Source§impl PartialOrd for SimpleFlag
impl PartialOrd for SimpleFlag
Source§impl Sub for SimpleFlag
impl Sub for SimpleFlag
Source§impl SubAssign for SimpleFlag
impl SubAssign for SimpleFlag
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