bittersweet
Bittersweet is a library for bit manipulation.
Motivation
Bit-wise operations are often used in low-level programming and it sometimes contains magical bugs. I want to manipulate bits with more
- type-safe
- well-tested
- well-documented
- fast and efficient
Usage
Installation
You can install this library via cargo.
Or you can add this to your Cargo.toml manually.
Example
use ;
Supported bitline length
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)
Documentation
See docs.rs
Manipulations
https://docs.rs/bittersweet/latest/bittersweet/bitline/trait.Bitline.html
as_emptyas_fullby_rangebytes_lengthlengthis_emptyis_not_emptyis_fullis_not_fullfirst_indexlast_indexradiusaroundwith_aroundfirst_bitlast_bitfirst_bitslast_bitsfilled_first_bit_to_last_bitnum_bitsbit_reprrangeincludesoverlapsrangeremove
License
BSD-3-Clause