Struct BitFlags

Source
pub struct BitFlags<T: RawBitFlags> { /* private fields */ }

Implementations§

Source§

impl<T> BitFlags<T>
where T: RawBitFlags,

Source

pub unsafe fn new(val: T::Type) -> Self

Create a new BitFlags unsafely. Consider using from_bits or from_bits_truncate.

Source§

impl<T> BitFlags<T>
where T: RawBitFlags,

Source

pub fn empty() -> Self

Create an empty BitFlags. Empty means 0.

Source

pub fn all() -> Self

Sets all flags.

Source

pub fn is_all(self) -> bool

Returns true if all flags are set

Source

pub fn is_empty(self) -> bool

Returns true if no flag is set

Source

pub fn bits(self) -> T::Type

Returns the underlying type value

Source

pub fn intersects<B: Into<BitFlags<T>>>(self, other: B) -> bool

Returns true if at least one flag is shared.

Source

pub fn contains<B: Into<BitFlags<T>>>(self, other: B) -> bool

Returns true iff all flags are contained.

Source

pub fn not(self) -> Self

Flips all flags

Source

pub fn from_bits(bits: T::Type) -> Option<Self>

Returns a BitFlags iff the bits value does not contain any illegal flags.

Source

pub fn from_bits_truncate(bits: T::Type) -> Self

Truncates flags that are illegal

Source

pub fn toggle<B: Into<BitFlags<T>>>(&mut self, other: B)

Toggles the matching bits

Source

pub fn insert<B: Into<BitFlags<T>>>(&mut self, other: B)

Inserts the flags into the BitFlag

Source

pub fn remove<B: Into<BitFlags<T>>>(&mut self, other: B)

Removes the matching flags

Trait Implementations§

Source§

impl<T, B> BitAnd<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

type Output = BitFlags<T>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: B) -> BitFlags<T>

Performs the & operation. Read more
Source§

impl<T, B> BitAndAssign<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

fn bitand_assign(&mut self, other: B)

Performs the &= operation. Read more
Source§

impl<T, B> BitOr<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

type Output = BitFlags<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: B) -> BitFlags<T>

Performs the | operation. Read more
Source§

impl<T, B> BitOrAssign<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

fn bitor_assign(&mut self, other: B)

Performs the |= operation. Read more
Source§

impl<T, B> BitXor<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

type Output = BitFlags<T>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: B) -> BitFlags<T>

Performs the ^ operation. Read more
Source§

impl<T, B> BitXorAssign<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

fn bitxor_assign(&mut self, other: B)

Performs the ^= operation. Read more
Source§

impl<T: Clone + RawBitFlags> Clone for BitFlags<T>
where T::Type: Clone,

Source§

fn clone(&self) -> BitFlags<T>

Returns a duplicate 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<T> Debug for BitFlags<T>

Source§

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

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

impl<T: RawBitFlags> From<T> for BitFlags<T>

Source§

fn from(t: T) -> BitFlags<T>

Converts to this type from the input type.
Source§

impl<T, B> FromIterator<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>>,

Source§

fn from_iter<I>(it: I) -> BitFlags<T>
where I: IntoIterator<Item = B>,

Creates a value from an iterator. Read more
Source§

impl<T> Not for BitFlags<T>
where T: RawBitFlags,

Source§

type Output = BitFlags<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> BitFlags<T>

Performs the unary ! operation. Read more
Source§

impl<T, B> PartialEq<B> for BitFlags<T>
where T: RawBitFlags, B: Into<BitFlags<T>> + Copy,

Source§

fn eq(&self, other: &B) -> 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<T: Copy + RawBitFlags> Copy for BitFlags<T>
where T::Type: Copy,

Auto Trait Implementations§

§

impl<T> Freeze for BitFlags<T>
where <T as RawBitFlags>::Type: Freeze,

§

impl<T> RefUnwindSafe for BitFlags<T>

§

impl<T> Send for BitFlags<T>
where <T as RawBitFlags>::Type: Send,

§

impl<T> Sync for BitFlags<T>
where <T as RawBitFlags>::Type: Sync,

§

impl<T> Unpin for BitFlags<T>
where <T as RawBitFlags>::Type: Unpin,

§

impl<T> UnwindSafe for BitFlags<T>
where <T as RawBitFlags>::Type: 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.