1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! The main type exported by the library, [`BV`](struct.BV.html), is a packed,
//! growable bit-vector. Its API mirrors that of `Vec` where reasonable. The
//! library also defines slice operations that return
//! [`BitSlice`](struct.BitSlice.html) or [`BitSliceMut`](struct.BitSliceMut.html),
//! akin to Rust’s array slices but for bit-vectors. A common API to
//! bit-vectors and bit-slices is provided by the [`BitVec`](trait.BitVec.html),
//! [`BitVecMut`](trait.BitVecMut.html), and [`BitVecPush`](trait.BitVecPush.html)
//! 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](https://crates.io/crates/bv), so you can add
//!
//! ```toml
//! [dependencies]
//! bv = "*"
//! ```
//!
//! to your `Cargo.toml` and
//!
//! ```rust
//! extern crate bv;
//! ```
//!
//! to your crate root.

#![warn(missing_docs)]

extern crate num_traits;

#[cfg(test)]
#[macro_use]
extern crate quickcheck;

#[macro_use]
mod macros;

mod storage;
pub use self::storage::BlockType;

mod traits;
pub use self::traits::{BitVec, BitVecMut, BitVecPush, BitSliceable};

mod slice;
pub use self::slice::{BitSlice, BitSliceMut, BitSliceBlockIter};

mod bv;
pub use self::bv::BV;

mod prims;