Struct enumflags2::FromBitsError [−][src]
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]
T::Type: Clone,
fn clone(&self) -> FromBitsError<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Copy + RawBitFlags> Copy for FromBitsError<T> where
T::Type: Copy,
[src]
T::Type: Copy,
impl<T: Debug + RawBitFlags> Debug for FromBitsError<T> where
T::Type: Debug,
[src]
T::Type: Debug,
impl<T: RawBitFlags + Debug> Display for FromBitsError<T>
[src]
Auto Trait Implementations
impl<T> Send for FromBitsError<T> where
<T as RawBitFlags>::Type: Send,
<T as RawBitFlags>::Type: Send,
impl<T> Sync for FromBitsError<T> where
<T as RawBitFlags>::Type: Sync,
<T as RawBitFlags>::Type: Sync,
impl<T> Unpin for FromBitsError<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<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>,