bit_op 0.1.1

Bit manipulation
Documentation
  • Coverage
  • 3.86%
    10 out of 259 items documented5 out of 6 items with examples
  • Size
  • Source code size: 15.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.48 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • RustyNixieTube/bit_op
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RustyNixieTube

License License line

Bit manipulation for rust

Examples

Set desired bits

use bit_op::{BitOp, bit_u8::*};

let mut x = 0b00001111u8;

x.set(B7);
assert_eq!(x, 0b10001111);

let mut y = 0u8;

y.set(B7 | B0);
assert_eq!(y, 0b10000001);

Reset desired bits

use bit_op::{BitOp, bit_u8::*};

let mut x = 0b00001111u8;

x.reset(B0 | B1 | B2 | B3);
assert_eq!(x, 0);

let mut y = 0b11111111u8;

y.reset(B7 | B0);
assert_eq!(y, 0b01111110);

Toggle desired bits

use bit_op::{BitOp, bit_u8::*};

let mut x = 0b00001111u8;

x.toggle(B5 | B4 | B3 | B2);
assert_eq!(x, 0b00110011);

x.toggle(B5 | B4 | B3 | B2);
assert_eq!(x, 0b00001111);

Get desired bits

use bit_op::{BitOp, bit_u8::*};

let mut x = 0b10000001u8;

assert_eq!(x.get(B7), 0b10000000);
assert_eq!(x.get(B6), 0b00000000);
assert_eq!(x.get(B0), 0b00000001);

Contribution

contributions are welcome!

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.