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

#612 in Memory management

Custom license

12KB
213 lines

stubit

stupid bit library.

Tests Crates.io Documentation

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:

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

No runtime deps