pub trait Flags: Sized + 'static {
type Bits: Bits;
const FLAGS: &'static [Flag<Self>];
Show 22 methods
fn bits(&self) -> Self::Bits;
fn from_bits_retain(bits: Self::Bits) -> Self;
fn empty() -> Self { ... }
fn all() -> Self { ... }
fn from_bits(bits: Self::Bits) -> Option<Self> { ... }
fn from_bits_truncate(bits: Self::Bits) -> Self { ... }
fn from_name(name: &str) -> Option<Self> { ... }
fn iter(&self) -> Iter<Self> ⓘ { ... }
fn iter_names(&self) -> IterNames<Self> ⓘ { ... }
fn is_empty(&self) -> bool { ... }
fn is_all(&self) -> bool { ... }
fn intersects(&self, other: Self) -> bool
where
Self: Sized,
{ ... }
fn contains(&self, other: Self) -> bool
where
Self: Sized,
{ ... }
fn insert(&mut self, other: Self)
where
Self: Sized,
{ ... }
fn remove(&mut self, other: Self)
where
Self: Sized,
{ ... }
fn toggle(&mut self, other: Self)
where
Self: Sized,
{ ... }
fn set(&mut self, other: Self, value: bool)
where
Self: Sized,
{ ... }
fn intersection(self, other: Self) -> Self { ... }
fn union(self, other: Self) -> Self { ... }
fn difference(self, other: Self) -> Self { ... }
fn symmetric_difference(self, other: Self) -> Self { ... }
fn complement(self) -> Self { ... }
}
Expand description
A set of flags.
This trait is automatically implemented for flags types defined using the bitflags!
macro.
It can also be implemented manually for custom flags types.
Required Associated Types§
Required Associated Constants§
Required Methods§
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).
Provided Methods§
sourcefn from_bits(bits: Self::Bits) -> Option<Self>
fn from_bits(bits: Self::Bits) -> Option<Self>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
Note that each multi-bit flag is treated as a unit for this comparison.
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.
Note that each multi-bit flag is treated as a unit for this comparison.
sourcefn iter_names(&self) -> IterNames<Self> ⓘ
fn iter_names(&self) -> IterNames<Self> ⓘ
Iterate over the raw names and bits for enabled flag values.
sourcefn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Returns true
if there are flags common to both self
and other
.
sourcefn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Returns true
if all of the flags in other
are contained within self
.
sourcefn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
Inserts the specified flags in-place.
This method is equivalent to union
.
sourcefn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
Removes the specified flags in-place.
This method is equivalent to difference
.
sourcefn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
Toggles the specified flags in-place.
This method is equivalent to symmetric_difference
.
sourcefn set(&mut self, other: Self, value: bool)where
Self: Sized,
fn set(&mut self, other: Self, value: bool)where
Self: Sized,
Inserts or removes the specified flags depending on the passed value.
sourcefn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
Returns the intersection between the flags in self
and other
.
sourcefn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
Returns the difference between the flags in self
and other
.
sourcefn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
Returns the symmetric difference between the flags
in self
and other
.
sourcefn complement(self) -> Self
fn complement(self) -> Self
Returns the complement of this set of flags.