dotbits

Crates.iodotbits
lib.rsdotbits
version0.3.0
sourcesrc
created_at2021-11-12 13:56:12.146658
updated_at2021-11-17 13:31:53.620095
descriptionunsigned int <-> Vec, plus various helper functions
homepage
repositoryhttps://github.com/ProspectPyxis/dotbits
max_upload_size
id480944
size28,128
(ProspectPyxis)

documentation

README

dotbits

unsigned int <-> Vec<bool>, plus helper functions

dotbits is a rust library that simplifies bit manipulation. Its primary feature is the .bits() function, which converts any unsigned integer type (u8, u16, u32, u64, u128, usize) into a Vec<bool>. It also adds certain helper functions over Vec<bool>.

WARNING: This crate is currently in the rapid iteration phase, and should not be considered stable. Certain methods may get added or removed very quickly between versions - use this crate at your own risk!

Usage

Add the following to your Cargo.toml:

[dependencies]
dotbits = "0.3"

Examples

Bit shifts using negative numbers:

use dotbits::BitManip;
assert_eq!(24u32.signed_left_shift(2), 24u32 << 2);
assert_eq!(24u32.signed_left_shift(-2), 24u32 >> 2);
assert_eq!(24u32.signed_right_shift(2), 24u32 >> 2);
assert_eq!(24u32.signed_right_shift(-2), 24u32 << 2);

License

dotbits is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Commit count: 78

cargo fmt