Search code examples
data-structuresrustbitvector

How do I use the unstable std::collections::BitVec?


I'm trying to use the std::collections::BitVec, but this error is generated:

error[E0432]: unresolved import `std::collections::BitVec`
 --> src\main.rs:6:5
  |
6 | use std::collections::BitVec;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ no `BitVec` in `collections`

I'm using #![feature(collections)] at the top of the main.rs and my compiler version is rustc 1.27.0-nightly (ac3c2288f 2018-04-18). What am I missing? The error is saying that BitVec doesn't exist at std::collections, but the docs say that BitVec is an unstable feature.

My Cargo.toml looks like:

[package]
name = "conways_game_of_life"
version = "0.1.0"
authors = ["Gabriel Carneiro <[email protected]>"]

# [lib]
# crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
rand = "0.4.2"
time = "*"

What am I supposed to do to use an unstable feature like BitVec?


Solution

  • You are looking at old documentation. BitVec was unstable in Rust 1.2, but you can see in the Rust 1.3 documentation that it was not stabilised, but instead moved into its own crate.