pub trait BitFlags: ImplementedByBitFlagsMacro {
type Bits: Bits;
type Iter: Iterator<Item = Self>;
type IterNames: Iterator<Item = (&'static str, Self)>;
Show 17 methods
// Required methods
fn empty() -> Self;
fn all() -> Self;
fn bits(&self) -> Self::Bits;
fn from_bits(bits: Self::Bits) -> Option<Self>
where Self: Sized;
fn from_bits_truncate(bits: Self::Bits) -> Self;
fn from_bits_retain(bits: Self::Bits) -> Self;
fn from_name(name: &str) -> Option<Self>
where Self: Sized;
fn iter(&self) -> Self::Iter;
fn iter_names(&self) -> Self::IterNames;
fn is_empty(&self) -> bool;
fn is_all(&self) -> bool;
fn intersects(&self, other: Self) -> bool;
fn contains(&self, other: Self) -> bool;
fn insert(&mut self, other: Self);
fn remove(&mut self, other: Self);
fn toggle(&mut self, other: Self);
fn set(&mut self, other: Self, value: bool);
}
Expand description
A trait that is automatically implemented for all bitflags.
It should not be implemented manually.
Required Associated Types§
Required Methods§
sourcefn from_bits(bits: Self::Bits) -> Option<Self>where
Self: Sized,
fn from_bits(bits: Self::Bits) -> Option<Self>where Self: Sized,
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcefn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
sourcefn from_bits_retain(bits: Self::Bits) -> Self
fn from_bits_retain(bits: Self::Bits) -> Self
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
sourcefn iter_names(&self) -> Self::IterNames
fn iter_names(&self) -> Self::IterNames
Iterate over the raw names and bits for enabled flag values.
sourcefn intersects(&self, other: Self) -> bool
fn intersects(&self, other: Self) -> bool
Returns true
if there are flags common to both self
and other
.