Crate bitfrob

Source
Expand description

A crate to help with bit manipulation of integers.

§Features

  • track_caller adds the #[track_caller] attribute on all the functions that assert stuff.

Structs§

U8BitIterHigh
Iterator for groups of bits in an integer (low to high).
U8BitIterLow
Iterator for groups of bits in an integer (low to high).
U16BitIterHigh
Iterator for groups of bits in an integer (low to high).
U16BitIterLow
Iterator for groups of bits in an integer (low to high).
U32BitIterHigh
Iterator for groups of bits in an integer (low to high).
U32BitIterLow
Iterator for groups of bits in an integer (low to high).
U64BitIterHigh
Iterator for groups of bits in an integer (low to high).
U64BitIterLow
Iterator for groups of bits in an integer (low to high).
U128BitIterHigh
Iterator for groups of bits in an integer (low to high).
U128BitIterLow
Iterator for groups of bits in an integer (low to high).
u8x2
Two u8 values packed as a u16.

Constants§

U8_SCALE_1_TO_8
When used as a multiplier, scales a “1 bit” u8 to spread the value across all 8 bits.
U8_SCALE_2_TO_8
When used as a multiplier, scales a “2 bit” u8 to spread the value across all 8 bits.
U8_SCALE_4_TO_8
When used as a multiplier, scales a “4 bit” u8 to spread the value across all 8 bits.

Functions§

u8_bit_split_1x8
Splits a byte into 1-bit chunks.
u8_bit_split_1x8_rev
Splits a byte into 1-bit chunks (reversed).
u8_bit_split_2x4
Splits a byte into 2-bit chunks.
u8_bit_split_2x4_rev
Splits a byte into 2-bit chunks (reversed).
u8_bit_split_4x2
Splits a byte into 4-bit chunks.
u8_bit_split_4x2_rev
Splits a byte into 4-bit chunks (reversed).
u8_get_bit
Determines if the b bit is set in u.
u8_get_region
Get the low to high bit region of u.
u8_get_value
Get the low to high bit region of u, down shifted by low.
u8_region_mask
Generates a bit mask where all bits in the region are 1.
u8_replicate_bits
Replicates the lowest count bits across the entire value.
u8_with_bit
Replaces the b bit in u.
u8_with_region
Replaces the low to high bit region of old.
u8_with_value
Replaces the low to high bit region of old with an input up shifted by low.
u16_get_bit
Determines if the b bit is set in u.
u16_get_region
Get the low to high bit region of u.
u16_get_value
Get the low to high bit region of u, down shifted by low.
u16_region_mask
Generates a bit mask where all bits in the region are 1.
u16_replicate_bits
Replicates the lowest count bits across the entire value.
u16_with_bit
Replaces the b bit in u.
u16_with_region
Replaces the low to high bit region of old.
u16_with_value
Replaces the low to high bit region of old with an input up shifted by low.
u32_get_bit
Determines if the b bit is set in u.
u32_get_region
Get the low to high bit region of u.
u32_get_value
Get the low to high bit region of u, down shifted by low.
u32_region_mask
Generates a bit mask where all bits in the region are 1.
u32_replicate_bits
Replicates the lowest count bits across the entire value.
u32_with_bit
Replaces the b bit in u.
u32_with_region
Replaces the low to high bit region of old.
u32_with_value
Replaces the low to high bit region of old with an input up shifted by low.
u64_get_bit
Determines if the b bit is set in u.
u64_get_region
Get the low to high bit region of u.
u64_get_value
Get the low to high bit region of u, down shifted by low.
u64_region_mask
Generates a bit mask where all bits in the region are 1.
u64_replicate_bits
Replicates the lowest count bits across the entire value.
u64_with_bit
Replaces the b bit in u.
u64_with_region
Replaces the low to high bit region of old.
u64_with_value
Replaces the low to high bit region of old with an input up shifted by low.
u128_get_bit
Determines if the b bit is set in u.
u128_get_region
Get the low to high bit region of u.
u128_get_value
Get the low to high bit region of u, down shifted by low.
u128_region_mask
Generates a bit mask where all bits in the region are 1.
u128_replicate_bits
Replicates the lowest count bits across the entire value.
u128_with_bit
Replaces the b bit in u.
u128_with_region
Replaces the low to high bit region of old.
u128_with_value
Replaces the low to high bit region of old with an input up shifted by low.