#portable #bit #manipulation #algorithms

no-std bitwise

Portable high-level bitwise manipulation algorithms

2 releases

Uses old Rust 2015

0.1.1 Feb 23, 2017
0.1.0 Feb 22, 2017

#4 in #manipulation

Download history 7/week @ 2022-01-28 4/week @ 2022-02-04 2/week @ 2022-02-11 8/week @ 2022-02-18 7/week @ 2022-02-25 5/week @ 2022-03-04 8/week @ 2022-03-11 10/week @ 2022-03-18 4/week @ 2022-03-25 6/week @ 2022-04-01 5/week @ 2022-04-08 8/week @ 2022-04-15 5/week @ 2022-04-22 10/week @ 2022-04-29 16/week @ 2022-05-06 39/week @ 2022-05-13

70 downloads per month

MIT license

115KB
2K SLoC

Portable high-level bitwise manipulation algorithms

crates.io version Travis build status Coveralls.io code coverage Docs License

We do what we must because we can.

The algorithms:

  • have descriptive names to ease reading code that performs bit manipulations,
  • often optimize to perfect assembly code (and always on nightly by using the bitintr crate),
  • works on stable unstable only :( due to specialization for now.

Example

extern crate bitwise;
use bitwise::word::*;

fn main() {
  let u = outer_perfect_shuffle(0b_1001_1111u8);
  let v = inner_perfect_shuffle(0b_1001_1111u8);
  let w = u.copy_bit(4u8, v, 3u8);
  assert_eq!(w.parallel_bits_deposit(u), 0b_1001_0011u8);
}

Supported compilers

The minimum required rustc version is >= 1.13.0.

Requires unstable for now.

Performance

Some algorithms like the Morton Z-Curve encoding/decoding routines switch implementation at compile-time depending on target features (like BMI2 support).

License

Licensed under the MIT license.

Acknowledgments

The giants that came before us:

Contribution

Yes please! Just note that all contributions shall be licensed as above without any additional terms or conditions.

Dependencies

~71KB