Struct enumflags2::BitFlags [−][src]
Represents a set of flags of some type T
.
The type must have the #[derive(BitFlags)]
attribute applied.
Implementations
impl<T> BitFlags<T> where
T: RawBitFlags,
[src]
T: RawBitFlags,
pub unsafe fn new(val: T::Type) -> Self
[src]
Create a new BitFlags unsafely, without checking if the bits form a valid bit pattern for the type.
Consider using from_bits
or from_bits_truncate
instead.
Safety
The argument must not have set bits at positions not corresponding to any flag.
pub fn empty() -> Self
[src]
Create an empty BitFlags. Empty means 0
.
pub fn all() -> Self
[src]
Create a BitFlags with all flags set.
pub fn is_all(self) -> bool
[src]
Returns true if all flags are set
pub fn is_empty(self) -> bool
[src]
Returns true if no flag is set
pub fn bits(self) -> T::Type
[src]
Returns the underlying type value
pub fn intersects<B: Into<BitFlags<T>>>(self, other: B) -> bool
[src]
Returns true if at least one flag is shared.
pub fn contains<B: Into<BitFlags<T>>>(self, other: B) -> bool
[src]
Returns true if all flags are contained.
pub fn from_bits(bits: T::Type) -> Result<Self, FromBitsError<T>>
[src]
Returns a BitFlags<T>
if the raw value provided does not contain
any illegal flags.
pub fn from_flag(flag: T) -> Self
[src]
Turn a T
into a BitFlags<T>
. Also available as flag.into()
.
pub fn from_bits_truncate(bits: T::Type) -> Self
[src]
Truncates flags that are illegal
pub fn toggle<B: Into<BitFlags<T>>>(&mut self, other: B)
[src]
Toggles the matching bits
pub fn insert<B: Into<BitFlags<T>>>(&mut self, other: B)
[src]
Inserts the flags into the BitFlag
pub fn remove<B: Into<BitFlags<T>>>(&mut self, other: B)
[src]
Removes the matching flags
pub fn iter(self) -> impl Iterator<Item = T>
[src]
Returns an iterator that yields each set flag
Trait Implementations
impl<T> Binary for BitFlags<T> where
T: RawBitFlags,
T::Type: Binary,
[src]
T: RawBitFlags,
T::Type: Binary,
impl<T, B> BitAnd<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
type Output = BitFlags<T>
The resulting type after applying the &
operator.
fn bitand(self, other: B) -> BitFlags<T>
[src]
impl<T, B> BitAndAssign<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
fn bitand_assign(&mut self, other: B)
[src]
impl<T, B> BitOr<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
type Output = BitFlags<T>
The resulting type after applying the |
operator.
fn bitor(self, other: B) -> BitFlags<T>
[src]
impl<T, B> BitOrAssign<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
fn bitor_assign(&mut self, other: B)
[src]
impl<T, B> BitXor<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
type Output = BitFlags<T>
The resulting type after applying the ^
operator.
fn bitxor(self, other: B) -> BitFlags<T>
[src]
impl<T, B> BitXorAssign<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
fn bitxor_assign(&mut self, other: B)
[src]
impl<T: Clone + RawBitFlags> Clone for BitFlags<T> where
T::Type: Clone,
[src]
T::Type: Clone,
fn clone(&self) -> BitFlags<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Copy + RawBitFlags> Copy for BitFlags<T> where
T::Type: Copy,
[src]
T::Type: Copy,
impl<T> Debug for BitFlags<T> where
T: RawBitFlags + Debug,
[src]
T: RawBitFlags + Debug,
impl<T> Default for BitFlags<T> where
T: RawBitFlags,
[src]
T: RawBitFlags,
The default value returned is one with all flags unset, i. e. empty
.
impl<T: Eq + RawBitFlags> Eq for BitFlags<T> where
T::Type: Eq,
[src]
T::Type: Eq,
impl<T, B> Extend<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
fn extend<I>(&mut self, it: I) where
I: IntoIterator<Item = B>,
[src]
I: IntoIterator<Item = B>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<T: RawBitFlags> From<T> for BitFlags<T>
[src]
impl<T, B> FromIterator<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>>,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>>,
fn from_iter<I>(it: I) -> BitFlags<T> where
I: IntoIterator<Item = B>,
[src]
I: IntoIterator<Item = B>,
impl<T: Hash + RawBitFlags> Hash for BitFlags<T> where
T::Type: Hash,
[src]
T::Type: Hash,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> LowerHex for BitFlags<T> where
T: RawBitFlags,
T::Type: LowerHex,
[src]
T: RawBitFlags,
T::Type: LowerHex,
impl<T> Not for BitFlags<T> where
T: RawBitFlags,
[src]
T: RawBitFlags,
type Output = BitFlags<T>
The resulting type after applying the !
operator.
fn not(self) -> BitFlags<T>
[src]
impl<T> Octal for BitFlags<T> where
T: RawBitFlags,
T::Type: Octal,
[src]
T: RawBitFlags,
T::Type: Octal,
impl<T, B> PartialEq<B> for BitFlags<T> where
T: RawBitFlags,
B: Into<BitFlags<T>> + Copy,
[src]
T: RawBitFlags,
B: Into<BitFlags<T>> + Copy,
impl<T: RawBitFlags> StructuralEq for BitFlags<T>
[src]
impl<T> TryFrom<u16> for BitFlags<T> where
T: RawBitFlags<Type = u16>,
[src]
T: RawBitFlags<Type = u16>,
type Error = FromBitsError<T>
The type returned in the event of a conversion error.
fn try_from(bits: T::Type) -> Result<Self, Self::Error>
[src]
impl<T> TryFrom<u32> for BitFlags<T> where
T: RawBitFlags<Type = u32>,
[src]
T: RawBitFlags<Type = u32>,
type Error = FromBitsError<T>
The type returned in the event of a conversion error.
fn try_from(bits: T::Type) -> Result<Self, Self::Error>
[src]
impl<T> TryFrom<u64> for BitFlags<T> where
T: RawBitFlags<Type = u64>,
[src]
T: RawBitFlags<Type = u64>,
type Error = FromBitsError<T>
The type returned in the event of a conversion error.
fn try_from(bits: T::Type) -> Result<Self, Self::Error>
[src]
impl<T> TryFrom<u8> for BitFlags<T> where
T: RawBitFlags<Type = u8>,
[src]
T: RawBitFlags<Type = u8>,
type Error = FromBitsError<T>
The type returned in the event of a conversion error.
fn try_from(bits: T::Type) -> Result<Self, Self::Error>
[src]
impl<T> TryFrom<usize> for BitFlags<T> where
T: RawBitFlags<Type = usize>,
[src]
T: RawBitFlags<Type = usize>,
type Error = FromBitsError<T>
The type returned in the event of a conversion error.
fn try_from(bits: T::Type) -> Result<Self, Self::Error>
[src]
impl<T> UpperHex for BitFlags<T> where
T: RawBitFlags,
T::Type: UpperHex,
[src]
T: RawBitFlags,
T::Type: UpperHex,
Auto Trait Implementations
impl<T> Send for BitFlags<T> where
<T as RawBitFlags>::Type: Send,
<T as RawBitFlags>::Type: Send,
impl<T> Sync for BitFlags<T> where
<T as RawBitFlags>::Type: Sync,
<T as RawBitFlags>::Type: Sync,
impl<T> Unpin for BitFlags<T> where
<T as RawBitFlags>::Type: Unpin,
<T as RawBitFlags>::Type: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,