Crates.io | bittersweet |
lib.rs | bittersweet |
version | 0.1.2 |
source | src |
created_at | 2022-08-10 03:59:17.353803 |
updated_at | 2023-07-17 05:08:07.763714 |
description | Add more intentional predicates to bitwise calcs. |
homepage | |
repository | |
max_upload_size | |
id | 642418 |
size | 59,481 |
Bittersweet is a library for bit manipulation.
Bit-wise operations are often used in low-level programming and it sometimes contains magical bugs. I want to manipulate bits with more
You can install this library via cargo.
$ cargo add bittersweet
Or you can add this to your Cargo.toml
manually.
use bittersweet::bitline::{Bitline, Bitline8};
fn main() {
let t = 0b00111000_u8 as Bitline8;
if t.includes(0b00110000_u8) {
println!("Yes!");
}
}
Following Bitline traits are implemented for u8
, u16
, u32
, u64
, u128
.
So these operations keep zero-cost abstraction.
Bitline8
... 8 bits (u8
)Bitline16
... 16 bits (u16
)Bitline32
... 32 bits (u32
)Bitline64
... 64 bits (u64
)Bitline128
... 128 bits (u128
)See docs.rs
https://docs.rs/bittersweet/latest/bittersweet/bitline/trait.Bitline.html
as_empty
as_full
by_range
bytes_length
length
is_empty
is_not_empty
is_full
is_not_full
first_index
last_index
radius
around
with_around
first_bit
last_bit
first_bits
last_bits
filled_first_bit_to_last_bit
num_bits
bit_repr
range
includes
overlaps
range
remove
BSD-3-Clause