pub struct ColorMask { /* private fields */ }
Implementations
impl ColorMask
impl ColorMask
pub const RED: ColorMask = Self{ bits: 1,}
pub const GREEN: ColorMask = Self{ bits: 2,}
pub const BLUE: ColorMask = Self{ bits: 4,}
pub const ALPHA: ColorMask = Self{ bits: 8,}
pub const fn from_bits(bits: u8) -> Option<ColorMask>
pub const fn from_bits(bits: u8) -> Option<ColorMask>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
pub const fn from_bits_truncate(bits: u8) -> ColorMask
pub const fn from_bits_truncate(bits: u8) -> ColorMask
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
pub const unsafe fn from_bits_unchecked(bits: u8) -> ColorMask
pub const unsafe fn from_bits_unchecked(bits: u8) -> ColorMask
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Safety
The caller of the bitflags!
macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked()
has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
pub const fn intersects(&self, other: ColorMask) -> bool
pub const fn intersects(&self, other: ColorMask) -> bool
Returns true
if there are flags common to both self
and other
.
pub const fn contains(&self, other: ColorMask) -> bool
pub const fn contains(&self, other: ColorMask) -> bool
Returns true
if all of the flags in other
are contained within self
.
pub fn set(&mut self, other: ColorMask, value: bool)
pub fn set(&mut self, other: ColorMask, value: bool)
Inserts or removes the specified flags depending on the passed value.
pub const fn intersection(self, other: ColorMask) -> ColorMask
pub const fn intersection(self, other: ColorMask) -> ColorMask
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
pub const fn union(self, other: ColorMask) -> ColorMask
pub const fn union(self, other: ColorMask) -> ColorMask
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
pub const fn difference(self, other: ColorMask) -> ColorMask
pub const fn difference(self, other: ColorMask) -> ColorMask
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
pub const fn symmetric_difference(self, other: ColorMask) -> ColorMask
pub const fn symmetric_difference(self, other: ColorMask) -> ColorMask
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
pub const fn complement(self) -> ColorMask
pub const fn complement(self) -> ColorMask
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
Trait Implementations
impl BitAndAssign<ColorMask> for ColorMask
impl BitAndAssign<ColorMask> for ColorMask
fn bitand_assign(&mut self, other: ColorMask)
fn bitand_assign(&mut self, other: ColorMask)
Disables all flags disabled in the set.
impl BitOrAssign<ColorMask> for ColorMask
impl BitOrAssign<ColorMask> for ColorMask
fn bitor_assign(&mut self, other: ColorMask)
fn bitor_assign(&mut self, other: ColorMask)
Adds the set of flags.
impl BitXorAssign<ColorMask> for ColorMask
impl BitXorAssign<ColorMask> for ColorMask
fn bitxor_assign(&mut self, other: ColorMask)
fn bitxor_assign(&mut self, other: ColorMask)
Toggles the set of flags.
impl Extend<ColorMask> for ColorMask
impl Extend<ColorMask> for ColorMask
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ColorMask>,
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ColorMask>,
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)impl FromIterator<ColorMask> for ColorMask
impl FromIterator<ColorMask> for ColorMask
fn from_iter<T>(iterator: T) -> ColorMaskwhere
T: IntoIterator<Item = ColorMask>,
fn from_iter<T>(iterator: T) -> ColorMaskwhere
T: IntoIterator<Item = ColorMask>,
impl Ord for ColorMask
impl Ord for ColorMask
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
impl PartialOrd<ColorMask> for ColorMask
impl PartialOrd<ColorMask> for ColorMask
fn partial_cmp(&self, other: &ColorMask) -> Option<Ordering>
fn partial_cmp(&self, other: &ColorMask) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl SubAssign<ColorMask> for ColorMask
impl SubAssign<ColorMask> for ColorMask
fn sub_assign(&mut self, other: ColorMask)
fn sub_assign(&mut self, other: ColorMask)
Disables all flags enabled in the set.
impl Copy for ColorMask
impl Eq for ColorMask
impl StructuralEq for ColorMask
impl StructuralPartialEq for ColorMask
Auto Trait Implementations
impl RefUnwindSafe for ColorMask
impl Send for ColorMask
impl Sync for ColorMask
impl Unpin for ColorMask
impl UnwindSafe for ColorMask
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
value
as a parameter of self
.