intbits

Crates.iointbits
lib.rsintbits
version0.2.0
sourcesrc
created_at2019-09-27 07:33:04.346979
updated_at2020-09-29 07:42:48.025096
descriptionEasy access to individual bits of integers
homepage
repositoryhttps://github.com/fusion-engineering/intbits
max_upload_size
id168037
size15,242
Mara Bos (m-ou-se)

documentation

README

intbits

Easy access to individual bits of integers

use intbits::Bits;

assert_eq!(2.bit(0), false);
assert_eq!(2.bit(1), true);
assert_eq!(2.bit(2), false);

assert_eq!(0b1011u32.bits(0..2), 0b11);
assert_eq!(0b1011u32.bits(2..4), 0b10);

assert_eq!(0xFFu8.with_bit(3, false), 0xF7);
assert_eq!(0xFFu8.with_bits(4..8, 3), 0x3F);

See the documentation.

Commit count: 17

cargo fmt