Struct BitFlags

Source
pub struct BitFlags<F, U>{ /* private fields */ }

Implementations§

Source§

impl<F, U> BitFlags<F, U>

Source

pub const unsafe fn from_flags_unchecked(flags: U) -> Self

Source

pub fn try_from_flags(flags: U) -> Option<Self>

Return None if the flags contains unknow toggled bit (greater than F::MAX)

Source

pub fn from_flags(flags: U) -> Self

Source

pub fn from_flag(flag: F) -> Self

Source

pub fn new() -> Self

Source

pub fn flags(self) -> U

Source§

impl<F, U> BitFlags<F, U>

Source

pub fn with(self, flag: F, set: bool) -> Self

Set the flag using a bool

Source

pub fn added(self, flag: F) -> Self

Set the flag to 1, even if the flag was already 1

Source

pub fn removed(self, flag: F) -> Self

Set the flag to 0, even if the flag was already 0

Source

pub fn toggled(self, flag: F) -> Self

Flip the flag transforming 1 <=> 0

Source

pub fn set(&mut self, flag: F, set: bool) -> &mut Self

Set the flag using a bool

Source

pub fn add(&mut self, flag: F) -> &mut Self

Set the flag to 1, even if the flag was already 1

Source

pub fn remove(&mut self, flag: F) -> &mut Self

Set the flag to 0, even if the flag was already 0

Source

pub fn toggle(&mut self, flag: F) -> &mut Self

Flip the flag transforming 1 <=> 0

Source

pub fn have(&self, flag: F) -> bool

Check if a flag is present

Source

pub fn have_any(&self, flags: &[F]) -> bool

Source

pub fn have_all(&self, flags: &[F]) -> bool

Trait Implementations§

Source§

impl<F, U> BitAnd<F> for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: F) -> Self::Output

Performs the & operation. Read more
Source§

impl<F, U> BitAnd for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<F, U> BitAndAssign<F> for BitFlags<F, U>

Source§

fn bitand_assign(&mut self, rhs: F)

Performs the &= operation. Read more
Source§

impl<F, U> BitAndAssign for BitFlags<F, U>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<F, U> BitOr<F> for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: F) -> Self::Output

Performs the | operation. Read more
Source§

impl<F, U> BitOr for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<F, U> BitOrAssign<F> for BitFlags<F, U>

Source§

fn bitor_assign(&mut self, rhs: F)

Performs the |= operation. Read more
Source§

impl<F, U> BitOrAssign for BitFlags<F, U>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<F, U> BitXor<F> for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: F) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<F, U> BitXor for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<F, U> BitXorAssign<F> for BitFlags<F, U>

Source§

fn bitxor_assign(&mut self, rhs: F)

Performs the ^= operation. Read more
Source§

impl<F, U> BitXorAssign for BitFlags<F, U>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<F, U> Clone for BitFlags<F, U>

Source§

fn clone(&self) -> BitFlags<F, U>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F, U> Debug for BitFlags<F, U>
where U: BitFlagsIntegerUnsigned + From<F>, F: MaxValue + Copy + TryFrom<U> + Debug, RangeInclusive<U>: Iterator<Item = U>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> DResult

Formats the value using the given formatter. Read more
Source§

impl<'de, F, U> Deserialize<'de> for BitFlags<F, U>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<F, U> From<F> for BitFlags<F, U>

Source§

fn from(value: F) -> Self

Converts to this type from the input type.
Source§

impl<F, U> Hash for BitFlags<F, U>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<F, U> IntoIterator for BitFlags<F, U>
where U: BitFlagsIntegerUnsigned + From<F>, F: MaxValue + Copy + TryFrom<U>, RangeInclusive<U>: Iterator<Item = U>,

Source§

type Item = F

The type of the elements being iterated over.
Source§

type IntoIter = BitFlagsIntoIter<F, U>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<F, U> Not for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<F, U> Ord for BitFlags<F, U>
where U: BitFlagsIntegerUnsigned + From<F> + Ord, F: MaxValue + Copy + Ord,

Source§

fn cmp(&self, other: &BitFlags<F, U>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<F, U> PartialEq for BitFlags<F, U>

Source§

fn eq(&self, other: &BitFlags<F, U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F, U> PartialOrd for BitFlags<F, U>

Source§

fn partial_cmp(&self, other: &BitFlags<F, U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<F, U> Serialize for BitFlags<F, U>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<F, U> Zero for BitFlags<F, U>

Source§

const ZERO: Self

The absorbing element of the multiplication such that x * X::ZERO = X::ZERO
Source§

fn zero() -> Self

Source§

fn set_zero(&mut self) -> &mut Self

Source§

fn is_zero(&self) -> bool
where Self: PartialEq,

Source§

fn is_non_zero(&self) -> bool
where Self: PartialEq,

Source§

impl<F, U> Copy for BitFlags<F, U>

Source§

impl<F, U> Eq for BitFlags<F, U>
where U: BitFlagsIntegerUnsigned + From<F> + Eq, F: MaxValue + Copy + Eq,

Source§

impl<F, U> StructuralPartialEq for BitFlags<F, U>

Auto Trait Implementations§

§

impl<F, U> Freeze for BitFlags<F, U>
where U: Freeze,

§

impl<F, U> RefUnwindSafe for BitFlags<F, U>

§

impl<F, U> Send for BitFlags<F, U>
where U: Send, F: Send,

§

impl<F, U> Sync for BitFlags<F, U>
where U: Sync, F: Sync,

§

impl<F, U> Unpin for BitFlags<F, U>
where U: Unpin, F: Unpin,

§

impl<F, U> UnwindSafe for BitFlags<F, U>
where U: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,