4 releases (2 breaking)
0.3.1 | Aug 30, 2023 |
---|---|
0.3.0 | Aug 29, 2023 |
0.2.0 | Aug 24, 2023 |
0.1.0 | Aug 24, 2023 |
#1282 in Encoding
12KB
213 lines
stubit
stu
pid bit
library.
Simple bit manipulation for stupid people like me.
Focus on ease of use and simplicity.
See Documentation for usage and examples.
License
Licensed under the Coffee License 1.0.
lib.rs
:
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));