Usage
Add this to your Cargo.toml:
[]
= "0.8"
Since Rust 2018, extern crate
is no longer mandatory. If your edition is old (Rust 2015),
add this to your crate root:
extern crate bit_vec;
If you want serde support, include the feature like this:
[]
= { = "0.8", = ["serde"] }
If you want to use bit-vec in a program that has #![no_std]
, just drop default features:
[]
= { = "0.8", = false }
If you want to use serde with the alloc crate instead of std, just use the serde_no_std
feature:
[]
= { = "0.8", = false, = ["serde", "serde_no_std"] }
If you want borsh-rs support, include it like this:
[]
= { = "0.8", = ["borsh"] }
Other available serialization libraries can be enabled with the
miniserde
and
nanoserde
features.
Description
Dynamic collections implemented with compact bit vectors.
Examples
This is a simple example of the Sieve of Eratosthenes which calculates prime numbers up to a given limit.
use BitVec;
let max_prime = 10000;
// Store the primes as a BitVec
let primes = ;
// Simple primality tests below our max bound
let print_primes = 20;
print!;
for x in 0..print_primes
println!;
let num_primes = primes.iter.filter.count;
println!;
assert_eq!;
License
Dual-licensed for compatibility with the Rust project.
Licensed under the Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0, or the MIT license: http://opensource.org/licenses/MIT, at your option.