pub struct ToIntLE<T> { /* private fields */ }
Expand description
Reduce to base 10 integer representations of bits. Leftmost is least significant.
§Examples
use optimal_binary::ToIntLE;
let to_int_le: ToIntLE<u8> = ToIntLE::new();
// It returns 0 when empty:
assert_eq!(to_int_le.decode([]), 0_u8);
// It returns the base 10 integer represented by binary bits:
assert_eq!(to_int_le.decode([false]), 0_u8);
assert_eq!(to_int_le.decode([false, false]), 0_u8);
assert_eq!(to_int_le.decode([false, false, false]), 0_u8);
assert_eq!(to_int_le.decode([true]), 1_u8);
assert_eq!(to_int_le.decode([true, true]), 3_u8);
assert_eq!(to_int_le.decode([true, true, true]), 7_u8);
// It treats leftmost as least significant:
assert_eq!(to_int_le.decode([false, true]), 2_u8);
assert_eq!(to_int_le.decode([false, false, true]), 4_u8);
Implementations§
Trait Implementations§
impl<T: Eq> Eq for ToIntLE<T>
impl<T> StructuralPartialEq for ToIntLE<T>
Auto Trait Implementations§
impl<T> Freeze for ToIntLE<T>where
T: Freeze,
impl<T> RefUnwindSafe for ToIntLE<T>where
T: RefUnwindSafe,
impl<T> Send for ToIntLE<T>where
T: Send,
impl<T> Sync for ToIntLE<T>where
T: Sync,
impl<T> Unpin for ToIntLE<T>where
T: Unpin,
impl<T> UnwindSafe for ToIntLE<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more