Crate bv [−] [src]
The main type exported by the library, BitVec, 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 Bits,
BitsMut, and BitsPush
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::{BitVec, BitsMut}; let mut bv1: BitVec = BitVec::new_fill(false, 50); let mut bv2: BitVec = BitVec::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.6"
to your Cargo.toml and
extern crate bv;
to your crate root.
This crate supports Rust version 1.20 and newer.
Macros
| bit_vec |
Like |
Structs
| 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 |
| BitVec |
A bit-vector, akin to |
Traits
| BitSliceable |
Types that support (re-)slicing by ranges. |
| Bits |
Read-only bit vector operations. |
| BitsMut |
Mutable bit vector operations that don’t affect the length. |
| BitsPush |
Bit vector operations that change the length. |
| BlockType |
Interface to primitive bit storage. |