Struct enumflags2::FromBitsError[][src]

pub struct FromBitsError<T: RawBitFlags> { /* fields omitted */ }

The error struct used by BitFlags::from_bits and the TryFrom implementation` for invalid values.

#[derive(Clone, Copy, Debug, BitFlags)]
#[repr(u8)]
enum MyFlags {
    A = 0b0001,
    B = 0b0010,
    C = 0b0100,
    D = 0b1000,
}

let result: Result<BitFlags<MyFlags>, _> = 0b10101u8.try_into();
assert!(result.is_err());
let error = result.unwrap_err();
assert_eq!(error.truncate(), MyFlags::C | MyFlags::A);
assert_eq!(error.invalid_bits(), 0b10000);

Implementations

impl<T: RawBitFlags> FromBitsError<T>[src]

pub fn truncate(self) -> BitFlags<T>[src]

Return the truncated result of the conversion.

pub fn invalid_bits(self) -> T::Type[src]

Return the bits that didn’t correspond to any flags.

Trait Implementations

impl<T: Clone + RawBitFlags> Clone for FromBitsError<T> where
    T::Type: Clone
[src]

impl<T: Copy + RawBitFlags> Copy for FromBitsError<T> where
    T::Type: Copy
[src]

impl<T: Debug + RawBitFlags> Debug for FromBitsError<T> where
    T::Type: Debug
[src]

impl<T: RawBitFlags + Debug> Display for FromBitsError<T>[src]

Auto Trait Implementations

impl<T> Send for FromBitsError<T> where
    <T as RawBitFlags>::Type: Send

impl<T> Sync for FromBitsError<T> where
    <T as RawBitFlags>::Type: Sync

impl<T> Unpin for FromBitsError<T> where
    <T as RawBitFlags>::Type: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.