Crate stubit

Source
Expand description

stupid bit library.

Crates.io Documentation

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 Bits.

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 Bits 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));

Macros§

bits
Creates Bits containing the arguments.

Structs§

Bit
Represents a single bit.
Bits
A contiguous growable vector of Bits with some helper functions to convert from and into integers.