Expand description
stu
pid bit
library.
Simple bit manipulation for stupid people like me.
Focus on ease of use and simplicity.
§Bit
Represents a single bit. Currently implemented with bool
.
Implements conversions from and into all integers.
§Bits
Represents a vector of Bit
s.
Implements convenient conversions from and into all integers.
let mut data = bits![0, 0, 1];
data.push(0);
assert_eq!(data.to_u8(), Ok(2));
If there are more Bit
s in Bits
than the integer can hold, it returns the value as Err
.
let data = Bits::from(260i32);
assert_eq!(data.to_i32(), Ok(260));
assert_eq!(data.to_i8(), Err(4));