Skip to main content

Crate bitkit

Crate bitkit 

Source
Expand description

§bits

Width-aware bit manipulation around a single Bits<T> newtype.

use bitkit::prelude::*;
let x = Bits::<u32>::new(0b1011_0000);
assert_eq!(x.isolate_lowest_set_bit(), Bits::new(0b0001_0000));
assert_eq!(x.set_bit(0)?,  Bits::new(0b1011_0001));
assert_eq!(x.extract(1..4)?, Bits::new(0b000));

§Modules

modulepurpose
BitsThe primary type; all bit operations are methods.
FlagsGeneric flag-set newtype.
alignPower-of-two alignment.
bytesRead/write integers from &[u8] with endianness.
formatAllocation-free grouped-binary Display.
explain (feature)Educational metadata for bit hacks.

Modules§

align
Power-of-two alignment over usize. align must be a non-zero power of two.
bytes
Read/write integers from &[u8] with explicit endianness. Never panics on short input.
explain
Educational metadata for common bit hacks. Feature explain.
format
Allocation-free grouped-binary Display wrapper.
morton
Morton (Z-order) curve encode / decode.
prelude
use bitkit::prelude::*; to import the common types.

Structs§

Bits
Width-typed wrapper around a primitive unsigned integer.
Flags
Flag set wrapping a primitive unsigned integer.

Enums§

BitError
Every fallible operation returns Result<_, BitError>.

Traits§

IntoBitRange
Accept either Range<u32> or (u32, u32) for bit-range arguments.