rev_bits

Crates.iorev_bits
lib.rsrev_bits
version0.1.2
sourcesrc
created_at2024-05-13 19:26:10.114127
updated_at2024-05-13 19:57:13.306757
descriptionreverses bits in a specified range
homepagehttps://github.com/xpe/rev_bits
repositoryhttps://github.com/xpe/rev_bits
max_upload_size
id1238781
size43,811
David James (xpe)

documentation

README

rev_bits

A Rust library for reversing bits for a specified range of an integer (u32 or u64).

Example

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

Crate

rev_bits is available on crates.io:

cargo add rev_bits

Test

rev_bits has extensive property-based tests thanks to QuickCheck:

cargo test

Benchmark

rev_bits has benchmarks thanks to Criterion.rs:

cargo bench
Commit count: 8

cargo fmt