Crate bv [−] [src]
The main type exported by the library, BV
, is a packed,
growable bit-vector. Its API mirrors that of Vec
where reasonable. The
library also defines slice operations that return
BitSlice
or BitSliceMut
,
akin to Rust’s array slices but for bit-vectors. A common API to
bit-vectors and bit-slices is provided by the BitVec
,
BitVecMut
, and BitVecPush
traits, which also allow treating all primitive unsigned integer types
(uN
), and vectors and slices thereof, as well as vectors and
slices of bool
, as bit-vectors.
Example
use bv::{BV, BitVecMut}; let mut bv1: BV = BV::new_fill(false, 50); let mut bv2: BV = BV::new_fill(false, 50); assert_eq!(bv1, bv2); bv1.set_bit(49, true); assert_ne!(bv1, bv2); assert_eq!(bv1.pop(), Some(true)); assert_eq!(bv2.pop(), Some(false)); assert_eq!(bv1, bv2);
Usage
It’s on crates.io, so you can add
[dependencies]
bv = "0.4"
to your Cargo.toml
and
extern crate bv;
to your crate root.
This crate supports Rust version 1.20 and newer.
Macros
bv |
Like |
Structs
BV |
A bit-vector, akin to |
BitSlice |
A slice of a bit-vector; akin to |
BitSliceBlockIter |
An iterator over the blocks of a bit slice. |
BitSliceMut |
A mutable slice of a bit-vector; akin to |
Traits
BitSliceable |
Types that support (re-)slicing by ranges. |
BitVec |
Read-only bit vector operations. |
BitVecMut |
Mutable bit vector operations that don’t affect the length. |
BitVecPush |
Bit vector operations that change the length. |
BlockType |
Interface to primitive bit storage. |