#bit #operations #macro #pattern #multiple #set #fiddling

bit_fiddler

Macros for common bit operations with multiple convenient patterns

5 releases (stable)

2.1.1 Nov 21, 2020
2.1.0 Nov 20, 2020
2.0.0 Nov 20, 2020
1.0.0 Nov 19, 2020
0.1.0 Nov 17, 2020

#2583 in Rust patterns


Used in lock-free-freelist

MIT/Apache

39KB
564 lines

bit_fiddler

Crate for common bit operations. Mainly for setting, toggling, unsetting and checking bits.

These operations are provided by macros which accept multiple patterns to allow easy bit fiddling. These include operations on a single bit, range of bits, etc. See macro docs for more details.

Macros in this crate don't do overflow/underflow checks. If invalid args are supplied, behaviour depends on the underlying operators and may panic.

Example

use bit_fiddler::set;

let mut bitmap = 0b_0000_0000;
set!(in bitmap, u8, [3..6]);
assert_eq!(bitmap, 0b_0011_1000);

Documentation is available on https://docs.rs/bit_fiddler


lib.rs:

Crate for common bit operations. Mainly for setting, toggling, unsetting and checking bits.

These operations are provided by macros which accept multiple patterns to allow easy bit fiddling. These include operations on a single bit, range of bits, etc. See macro docs for more details.

Macros in this crate don't do overflow/underflow checks. If invalid args are supplied, behaviour depends on the underlying operators and may panic.

Example

use bit_fiddler::set;

let mut bitmap = 0b_0000_0000;
set!(in bitmap, u8, [3..6]);
assert_eq!(bitmap, 0b_0011_1000);

No runtime deps