Skip to main content

BitFlags

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) -> BitFlags<F, U>

Source

pub fn try_from_flags(flags: U) -> Option<BitFlags<F, U>>

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

Source

pub fn from_flags(flags: U) -> BitFlags<F, U>

Source

pub fn from_flag(flag: F) -> BitFlags<F, U>

Source

pub fn new() -> BitFlags<F, U>

Source

pub fn flags(self) -> U

Source§

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

Source

pub fn with(self, flag: F, set: bool) -> BitFlags<F, U>

Set the flag using a bool

Source

pub fn added(self, flag: F) -> BitFlags<F, U>

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

Source

pub fn removed(self, flag: F) -> BitFlags<F, U>

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

Source

pub fn toggled(self, flag: F) -> BitFlags<F, U>

Flip the flag transforming 1 <=> 0

Source

pub fn set(&mut self, flag: F, set: bool) -> &mut BitFlags<F, U>

Set the flag using a bool

Source

pub fn add(&mut self, flag: F) -> &mut BitFlags<F, U>

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

Source

pub fn remove(&mut self, flag: F) -> &mut BitFlags<F, U>

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

Source

pub fn toggle(&mut self, flag: F) -> &mut BitFlags<F, U>

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 for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: BitFlags<F, U>) -> <BitFlags<F, U> as BitAnd>::Output

Performs the & operation. Read more
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) -> <BitFlags<F, U> as BitAnd<F>>::Output

Performs the & operation. Read more
Source§

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

Source§

fn bitand_assign(&mut self, rhs: BitFlags<F, U>)

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> BitOr for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: BitFlags<F, U>) -> <BitFlags<F, U> as BitOr>::Output

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) -> <BitFlags<F, U> as BitOr<F>>::Output

Performs the | operation. Read more
Source§

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

Source§

fn bitor_assign(&mut self, rhs: BitFlags<F, U>)

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> BitXor for BitFlags<F, U>

Source§

type Output = BitFlags<F, U>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: BitFlags<F, U>) -> <BitFlags<F, U> as BitXor>::Output

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) -> <BitFlags<F, U> as BitXor<F>>::Output

Performs the ^ operation. Read more
Source§

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

Source§

fn bitxor_assign(&mut self, rhs: BitFlags<F, U>)

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> Clone for BitFlags<F, U>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

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

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<'_>) -> Result<(), Error>

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

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

Available on crate feature serde only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<BitFlags<F, U>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

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

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

Source§

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

Source§

fn from(value: F) -> BitFlags<F, U>

Converts to this type from the input type.
Source§

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

Source§

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

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) -> <BitFlags<F, U> as IntoIterator>::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) -> <BitFlags<F, U> as Not>::Output

Performs the unary ! operation. Read more
Source§

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

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

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

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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>

Available on crate feature serde only.
Source§

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

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

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

Source§

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

Source§

const ZERO: BitFlags<F, U>

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,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

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

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<Src, Dest> CastFrom<Dest> for Src
where Dest: CastInto<Src>,

Source§

fn cast_from(value: Dest) -> Src

Source§

impl<Src, Dest> CastRangeFrom<Dest> for Src
where Dest: CastRangeInto<Src>,

Source§

fn cast_range_from(value: Dest) -> Src

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<I, T> CollectExtension<T> for I
where I: IntoIterator<Item = T>,

Source§

fn to_vec(self) -> Vec<T>

Source§

fn to_linkedlist(self) -> LinkedList<T>

Source§

fn to_vecdeque(self) -> VecDeque<T>

Source§

fn to_hashset(self) -> HashSet<T>
where T: Eq + Hash,

Source§

fn to_btreeset(self) -> BTreeSet<T>
where T: Ord,

Source§

impl<I, T1> CollectToGenVecExtension<T1> for I
where I: IntoIterator<Item = T1>,

Source§

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

Source§

impl<C, T, const N: usize> ExtensionFromArray<T, N> for C
where C: From<[T; N]>,

Source§

fn from_array(value: [T; N]) -> Self

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PartialOrdExtension for T
where T: PartialOrd,

Source§

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

Source§

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

Source§

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PositiveOrNegative for T
where T: Zero + PartialOrd,

Source§

impl<T> SplatCoord1 for T
where T: Copy,

Source§

fn splat1(self) -> Vector<Self, 1>

Source§

impl<T> SplatCoord2 for T
where T: Copy,

Source§

fn splat2(self) -> Vector<Self, 2>

Source§

impl<T> SplatCoord3 for T
where T: Copy,

Source§

fn splat3(self) -> Vector<Self, 3>

Source§

impl<T> SplatCoord4 for T
where T: Copy,

Source§

fn splat4(self) -> Vector<Self, 4>

Source§

impl<T> ToDebug for T
where T: Debug,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.