Crates.io | rev_bits |
lib.rs | rev_bits |
version | 0.1.2 |
source | src |
created_at | 2024-05-13 19:26:10.114127 |
updated_at | 2024-05-13 19:57:13.306757 |
description | reverses bits in a specified range |
homepage | https://github.com/xpe/rev_bits |
repository | https://github.com/xpe/rev_bits |
max_upload_size | |
id | 1238781 |
size | 43,811 |
A Rust library for reversing bits for a specified range of an integer (u32
or u64
).
let x: u32 = 0xF0FFA000;
let y = reverse(x, 8..16);
println!("original: {:08X}", x);
println!(" changed: {}", "....xx..");
println!("reversed: {:08X}", y);
Gives:
original: F0FFA000
changed: ....xx..
reversed: F0FF0500
rev_bits
is available on crates.io:
cargo add rev_bits
rev_bits
has extensive property-based tests thanks to QuickCheck:
cargo test
rev_bits
has benchmarks thanks to Criterion.rs:
cargo bench