Bug 1538161 - Vendor rust_cascade r=keeler
☠☠ backed out by 566576f30c36 ☠ ☠
authorMark Goodwin <mgoodwin@mozilla.com>
Mon, 29 Apr 2019 14:04:07 +0000
changeset 530560 3fa81f747c9399c04c3c9b7bd76acedcfe3c21dd
parent 530559 dde986f8138db1c196ddaa173271239a3de0c925
child 530561 566576f30c365fc4238589af31bf9c37f10b3eaa
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1538161
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538161 - Vendor rust_cascade r=keeler Differential Revision: https://phabricator.services.mozilla.com/D24557
Cargo.lock
security/manager/ssl/cert_storage/Cargo.toml
third_party/rust/bitvec/.cargo-checksum.json
third_party/rust/bitvec/.editorconfig
third_party/rust/bitvec/.gitmodules
third_party/rust/bitvec/.travis.yml
third_party/rust/bitvec/AUTHORS.txt
third_party/rust/bitvec/CHANGELOG.md
third_party/rust/bitvec/CODE_OF_CONDUCT.md
third_party/rust/bitvec/CONTRIBUTING.md
third_party/rust/bitvec/Cargo.toml
third_party/rust/bitvec/Justfile
third_party/rust/bitvec/LICENSE.txt
third_party/rust/bitvec/README.md
third_party/rust/bitvec/doc/Bit Patterns.md
third_party/rust/bitvec/examples/readme.rs
third_party/rust/bitvec/examples/serdes.rs
third_party/rust/bitvec/examples/sieve.rs
third_party/rust/bitvec/examples/tour.rs
third_party/rust/bitvec/src/bits.rs
third_party/rust/bitvec/src/boxed.rs
third_party/rust/bitvec/src/cursor.rs
third_party/rust/bitvec/src/domain.rs
third_party/rust/bitvec/src/lib.rs
third_party/rust/bitvec/src/macros.rs
third_party/rust/bitvec/src/pointer.rs
third_party/rust/bitvec/src/prelude.rs
third_party/rust/bitvec/src/serdes.rs
third_party/rust/bitvec/src/slice.rs
third_party/rust/bitvec/src/vec.rs
third_party/rust/byteorder/.cargo-checksum.json
third_party/rust/byteorder/CHANGELOG.md
third_party/rust/byteorder/Cargo.toml
third_party/rust/byteorder/benches/bench.rs
third_party/rust/byteorder/build.rs
third_party/rust/byteorder/src/io.rs
third_party/rust/byteorder/src/lib.rs
third_party/rust/murmurhash3/.cargo-checksum.json
third_party/rust/murmurhash3/CHANGELOG.rst
third_party/rust/murmurhash3/Cargo.toml
third_party/rust/murmurhash3/LICENSE
third_party/rust/murmurhash3/README.rst
third_party/rust/murmurhash3/src/hasher.rs
third_party/rust/murmurhash3/src/lib.rs
third_party/rust/murmurhash3/src/mmh3_128.rs
third_party/rust/murmurhash3/src/mmh3_32.rs
third_party/rust/rust_cascade/.cargo-checksum.json
third_party/rust/rust_cascade/Cargo.toml
third_party/rust/rust_cascade/README.md
third_party/rust/rust_cascade/license.txt
third_party/rust/rust_cascade/src/lib.rs
third_party/rust/rust_cascade/test_data/test_bf
third_party/rust/rust_cascade/test_data/test_mlbf
third_party/rust/rust_cascade/test_data/test_short_mlbf
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -173,26 +173,26 @@ dependencies = [
  "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "base64"
 version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "base64"
 version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "bench-collections-gtest"
 version = "0.1.0"
 dependencies = [
  "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -216,17 +216,17 @@ dependencies = [
  "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "bincode"
 version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "bindgen"
 version = "0.49.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
@@ -319,32 +319,37 @@ dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "moz_task 0.1.0",
  "nserror 0.1.0",
  "nsstring 0.1.0",
  "xpcom 0.1.0",
 ]
 
 [[package]]
+name = "bitvec"
+version = "0.11.0"
+source = "git+https://github.com/mozmark/bitvec?branch=20190426-bitvec-vendor-issues#fd9393e92a0d4223b3bda7318ca5fb893f7632e1"
+
+[[package]]
 name = "blake2-rfc"
 version = "0.2.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "block-buffer"
 version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "block-padding"
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
@@ -381,25 +386,25 @@ source = "registry+https://github.com/ru
 
 [[package]]
 name = "byte-tools"
 version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "byteorder"
-version = "1.2.7"
+version = "1.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "bytes"
 version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "bzip2"
 version = "0.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
@@ -433,16 +438,17 @@ dependencies = [
  "base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "lmdb-rkv 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "moz_task 0.1.0",
  "nserror 0.1.0",
  "nsstring 0.1.0",
  "rkv 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rust_cascade 0.3.2 (git+https://github.com/mozmark/rust-cascade?branch=20190426-bitvec-vendor-issues)",
  "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "style 0.0.1",
  "thin-vec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "xpcom 0.1.0",
 ]
 
 [[package]]
@@ -836,17 +842,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "deflate"
 version = "0.7.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "derive_common"
 version = "0.0.1"
 dependencies = [
  "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1138,17 +1144,17 @@ dependencies = [
  "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "fxhash"
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "gcc"
 version = "0.3.54"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -1310,34 +1316,34 @@ dependencies = [
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
 
 [[package]]
 name = "h2"
 version = "0.1.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
  "http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "hashbrown"
 version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "scopeguard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "hashglobe"
 version = "0.1.0"
 dependencies = [
  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1406,17 +1412,17 @@ dependencies = [
  "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "image"
 version = "0.21.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1875,31 +1881,31 @@ dependencies = [
  "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "mp4parse"
 version = "0.11.2"
 dependencies = [
  "bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "mp4parse_fallible 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "mp4parse-gtest"
 version = "0.1.0"
 
 [[package]]
 name = "mp4parse_capi"
 version = "0.11.2"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "mp4parse 0.11.2",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "mp4parse_fallible"
 version = "0.0.1"
@@ -1910,16 +1916,21 @@ name = "msdos_time"
 version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
 
 [[package]]
+name = "murmurhash3"
+version = "0.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
 name = "net2"
 version = "0.2.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
@@ -2180,17 +2191,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "plist"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
  "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "png"
 version = "0.14.0"
@@ -2435,16 +2446,28 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rust-ini"
 version = "0.10.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
+name = "rust_cascade"
+version = "0.3.2"
+source = "git+https://github.com/mozmark/rust-cascade?branch=20190426-bitvec-vendor-issues#86c24aa1f2f9de1b4b5e1bb451255d530ac7c03f"
+dependencies = [
+ "bitvec 0.11.0 (git+https://github.com/mozmark/bitvec?branch=20190426-bitvec-vendor-issues)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "murmurhash3 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "rustc-demangle"
 version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rustc_version"
 version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2714,17 +2737,17 @@ source = "registry+https://github.com/ru
 name = "style"
 version = "0.0.1"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bindgen 0.49.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "fallible 0.0.1",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hashglobe 0.1.0",
  "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3316,17 +3339,17 @@ dependencies = [
 
 [[package]]
 name = "webrender"
 version = "0.60.0"
 dependencies = [
  "base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3354,17 +3377,17 @@ dependencies = [
 
 [[package]]
 name = "webrender_api"
 version = "0.60.0"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.88 (git+https://github.com/servo/serde?branch=deserialize_from_enums10)",
@@ -3463,17 +3486,17 @@ dependencies = [
  "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "ws"
 version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "mio 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
  "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3581,23 +3604,24 @@ dependencies = [
 "checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff"
 "checksum bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0"
 "checksum bindgen 0.49.0 (registry+https://github.com/rust-lang/crates.io-index)" = "33e1b67a27bca31fd12a683b2a3618e275311117f48cfcc892e18403ff889026"
 "checksum binjs_meta 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "430239e4551e42b80fa5d92322ac80ea38c9dda56e5d5582e057e2288352b71a"
 "checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a"
 "checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf"
 "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
 "checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707"
+"checksum bitvec 0.11.0 (git+https://github.com/mozmark/bitvec?branch=20190426-bitvec-vendor-issues)" = "<none>"
 "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
 "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
 "checksum block-padding 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc4358306e344bf9775d0197fd00d2603e5afb0771bb353538630f022068ea3"
 "checksum boxfnonce 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8380105befe91099e6f69206164072c05bc92427ff6aa8a5171388317346dd75"
 "checksum build_const 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e90dc84f5e62d2ebe7676b83c22d33b6db8bd27340fb6ffbff0a364efa0cb9c9"
 "checksum byte-tools 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "980479e6fde23246dfb54d47580d66b4e99202e7579c5eaa9fe10ecb5ebd2182"
-"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
+"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
 "checksum bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e178b8e0e239e844b083d5a0d4a156b2654e67f9f80144d48398fcd736a24fb8"
 "checksum bzip2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3eafc42c44e0d827de6b1c131175098fe7fb53b8ce8a47e65cb3ea94688be24"
 "checksum bzip2-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2c5162604199bbb17690ede847eaa6120a3f33d5ab4dcc8e7c25b16d849ae79b"
 "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
 "checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd"
 "checksum cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc0086be9ca82f7fc89fc873435531cb898b86e850005850de1f820e2db6e9b"
 "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
 "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
@@ -3722,16 +3746,17 @@ dependencies = [
 "checksum miniz_oxide_c_api 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92d98fdbd6145645828069b37ea92ca3de225e000d80702da25c20d3584b38a5"
 "checksum mio 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "4fcfcb32d63961fb6f367bfd5d21e4600b92cd310f71f9dca25acae196eb1560"
 "checksum mio-named-pipes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "82f43a815b57d2d652550f3d20cec88a495bb2d0956aa873dc43040278455677"
 "checksum mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1731a873077147b626d89cc6c2a0db6288d607496c5d10c0cfcf3adc697ec673"
 "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
 "checksum moz_cbor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20c82a57087fd5990d7122dbff1607c3b20c3d2958e9d9ad9765aab415e2c91c"
 "checksum mp4parse_fallible 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6626c2aef76eb8f984eef02e475883d3fe9112e114720446c5810fc5f045cd30"
 "checksum msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aad9dfe950c057b1bfe9c1f2aa51583a8468ef2a5baba2ebbe06d775efeb7729"
+"checksum murmurhash3 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
 "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
 "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"
 "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
 "checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
 "checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
 "checksum num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c31b75c36a993d30c7a13d70513cb93f02acafdd5b7ba250f9b0e18615de7"
 "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
 "checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
@@ -3777,16 +3802,17 @@ dependencies = [
 "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
 "checksum regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d8c9f33201f46669484bacc312b00e7541bed6aaf296dffe2bb4e0ac6b8ce2a"
 "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
 "checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"
 "checksum rkv 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "238764bd8750927754d91e4a27155ac672ba88934a2bf698c992d55e5ae25e5b"
 "checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
 "checksum runloop 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d79b4b604167921892e84afbbaad9d5ad74e091bf6c511d9dbfb0593f09fabd"
 "checksum rust-ini 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8a654c5bda722c699be6b0fe4c0d90de218928da5b724c3e467fc48865c37263"
+"checksum rust_cascade 0.3.2 (git+https://github.com/mozmark/rust-cascade?branch=20190426-bitvec-vendor-issues)" = "<none>"
 "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649"
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 "checksum ryu 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0568787116e13c652377b6846f5931454a363a8fdf8ae50463ee40935b278b"
 "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
 "checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
 "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d"
 "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
 "checksum scopeguard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c79eb2c3ac4bc2507cda80e7f3ac5b88bd8eae4c0914d5663e6a8933994be918"
--- a/security/manager/ssl/cert_storage/Cargo.toml
+++ b/security/manager/ssl/cert_storage/Cargo.toml
@@ -7,13 +7,14 @@ authors = ["Dana Keeler <dkeeler@mozilla
 base64 = "0.10"
 crossbeam-utils = "0.6.3"
 lmdb-rkv = "0.11"
 log = "0.4"
 moz_task = { path = "../../../../xpcom/rust/moz_task" }
 nserror = { path = "../../../../xpcom/rust/nserror" }
 nsstring = { path = "../../../../xpcom/rust/nsstring" }
 rkv = "^0.9"
+rust_cascade = { git = "https://github.com/mozmark/rust-cascade", branch = "20190426-bitvec-vendor-issues" }
 sha2 = "^0.8"
 style = { path = "../../../../servo/components/style" }
 thin-vec = { version = "0.1.0", features = ["gecko-ffi"] }
 time = "0.1"
 xpcom = { path = "../../../../xpcom/rust/xpcom" }
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/.cargo-checksum.json
@@ -0,0 +1,1 @@
+{"files":{".editorconfig":"ad2ddd2235a1ca26d8be9df333baae560b8f696f9475a8084d5169bc598feced",".gitmodules":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"e3d5a6154d4ad058f85387f2bd0ff369185c74eab6c877222bffa26cb94cbb43","AUTHORS.txt":"2bdfa77827b6fd352f398752c30acbca48ada04284656b6d38fb97b85534d5bf","CHANGELOG.md":"7247fb1b50a9d1d278f01918d4143a5055eed27bbbb7d815e5dd866eea23d265","CODE_OF_CONDUCT.md":"bae3bf173a3748f4b62eb808133bb1597f811f0fa919e997149882125f91746d","CONTRIBUTING.md":"035ebfb837464470c7649e6b306c7f0b831c242cbbf25fb97a0b3f40ea4acde6","Cargo.toml":"c7ad5c8b5d8fa6da8aed9afc587f90ea50bd5143b9242d67196d9bfc7f06e775","Justfile":"f40ee5a5a5b3dbbebf90d6704909029b680bc5a3b3084e2792897995e833bcb2","LICENSE.txt":"411781fd38700f2357a14126d0ab048164ab881f1dcb335c1bb932e232c9a2f5","README.md":"06220e7785d27d8899aa5b27e3f8914225aa1d2a79a44142d8eb76cbe4c76820","doc/Bit Patterns.md":"cfd36f3ec70df5541c37f4c25a59211a3eccc3cc5d189efb4a61eb5d4f2357df","examples/readme.rs":"25de2cee995538d755149cbd1050e521ac92c852dd0d9da1f1c2c8cbc24704f7","examples/serdes.rs":"08df19dc1d83d75bf159f06c502469ccf8aa7ccaafca00cf6ad015def4dfcf94","examples/sieve.rs":"a827fcf1749987b4fd3182b9dcc5843a79062a9ed3f45ffc32a32fe6cc589b40","examples/tour.rs":"b489ab7706777360b1a2eb374326dc302fd7f861a94f19489c2fd89a9e2edd6e","src/bits.rs":"3cbf151e51ae0788ec25ba3da7b0b2602d2406bbd2d6c656f6ecfc1198646217","src/boxed.rs":"a1c7a82b0e99a8935ebdf9cfcd81c4bf8c3318b8f68a0098cd674fbea62a5190","src/cursor.rs":"12fb0c0397b95ca5ec781c597399dcbc8c613085e37a4c8b9aed52ec71429563","src/domain.rs":"ee48d5d9730103d5b4ec2d2033916511e2e3e3ea8e6d5b02b0865871ff654777","src/lib.rs":"e9ff103498255208e952aba0826736c07d31d626503f2264ec68359c7cc0367a","src/macros.rs":"9bbc09012519dcdd27fc8153b3d0b5c77c9d2501caa41ec3d82598929c1b493a","src/pointer.rs":"78edf17c31976e87a9244ce7d7315a89b99e3f7e295a7b0901d4ef9e1e4c31c7","src/prelude.rs":"355767c31fe1da51b28b6aeda4150b54e7966f1762b6d4cd5425ac2060d78419","src/serdes.rs":"f1c22be942230f119e2b622a88930058c2be69c3f4b48d25b17e61e655514083","src/slice.rs":"63bfe42e69251a439bbc60c0c3c95d4ca040f17cd5a68c27d238718a2639e864","src/vec.rs":"e04056e7529a4fe0cce76a139f928cf385f99b2869cf69dd86291ae4b490fea5"},"package":null}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/.editorconfig
@@ -0,0 +1,21 @@
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+indent_size = 2
+indent_style = space
+
+[*.rs]
+indent_size = 4
+indent_style = tab
+
+[*.toml]
+indent_size = 8
+indent_style = tab
+
+[*.yml]
+indent_size = 2
+indent_style = space
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/.travis.yml
@@ -0,0 +1,40 @@
+language: rust
+
+sudo: required
+
+rust:
+  - stable
+  - beta
+  - nightly
+
+matrix:
+  allow_failures:
+    - rust: nightly
+
+# codecov
+addons:
+  apt:
+    packages:
+      - libcurl4-openssl-dev
+      - libelf-dev
+      - libdw-dev
+      - cmake
+      - gcc
+      - binutils-dev
+      - libiberty-dev
+
+# codecov
+after_success: |
+  wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
+  tar xzf master.tar.gz &&
+  cd kcov-master &&
+  mkdir build &&
+  cd build &&
+  cmake .. &&
+  make &&
+  make install DESTDIR=../../kcov-build &&
+  cd ../.. &&
+  rm -rf kcov-master &&
+  for file in target/debug/bitvec-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
+  bash <(curl -s https://codecov.io/bash) &&
+  echo "Uploaded code coverage"
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/AUTHORS.txt
@@ -0,0 +1,1 @@
+myrrlyn <self@myrrlyn.dev>
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/CHANGELOG.md
@@ -0,0 +1,260 @@
+# Changelog
+
+All notable changes will be documented in this file.
+
+## 0.11.0
+
+This contains the last (planned) compiler version upgrade, to `1.33.0`, and the
+last major feature add before `1.0`: Serde-powered de/serialization.
+
+Deserialization is not possible without access to an allocator, so it is behind
+a feature gate, `serdes`, which depends on the `alloc` feature.
+
+`BitSlice`, `BitBox`, and `BitVec` all support serialization, and `BitBox` and
+`BitVec` support deserialization
+
+### Added
+
+- `serdes` feature to serialize `BitSlice`, `BitBox`, and `BitVec`, and
+  deserialize `BitBox` and `BitVec`.
+- `change_cursor<D>` method on `BitSlice`, `BitBox`, and `BitVec`, which enable
+  changing the element traversal order on a data set without modifying that
+  data. This is useful for working with slices that have their cursor type
+  erased, such as crossing serialization or foreign-language boundaries.
+- Internal domain models for the memory regions governed by `BitPtr`. These
+  models provide improved logical support for manipulating bit sequences with as
+  little inefficiency as possible.
+- `BitPtr::bare_parts` and `BitPtr::region_data` internal APIs for accessing
+  components of the pointer structure.
+- Clippy is now part of the development routine.
+
+### Changed
+
+- The internal `Bits` trait uses a `const fn` stabilized in `1.33.0` in order to
+  compute type information, rather than requiring explicit statements in the
+  implementations.
+
+## 0.10.1
+
+Bugfix for [Issue #7](https://github.com/myrrlyn/bitvec/issues/7).
+`BitSlice::count_ones` and `BitSlice::count_zeros` counted the total number of
+bits present in a slice, not the number of bits set or unset, when operating
+inside a single element.
+
+The small case used `.map().count()`, but the large case correctly used
+`.map().filter().count()`. The missing `.filter()` call, to remove unset or set
+bits from the counting, was the cause of the bug.
+
+Thanks to GitHub user [@geq1t](https://github.com/geq1t) for the report!
+
+## 0.10.0
+
+This version was a complete rewrite of the entire crate. The minimum compiler
+version has been upgraded to `1.31.0`. The crate is written against the Rust
+2018 edition of the language. It will be a `1.0` release after polishing.
+
+### Added
+
+- `BitPtr` custom pointer representation. This is the most important component
+  of the rewrite, and what enabled the expanded feature set and API surface.
+  This structure allows `BitSlice` and `BitVec` to have head cursors at any bit,
+  not just at the front edge of an element. This allows the crate to support
+  arbitrary range slicing and slice splitting, and in turn greatly expand the
+  usability of the slice and vector types.
+
+  The `BitPtr` type is wholly crate-internal, and renders the `&BitSlice` and
+  `BitVec` handle types ***wholly incompatible*** with standard Rust slice and
+  vector handles. With great power comes great responsibility to never, ever,
+  interchange these types through any means except the provided translation API.
+
+- Range indexing and more powerful iteration. Bit-precision addressing allows
+  arbitrary subslices and enables more of the slice API from `core`.
+
+### Changed
+
+- Almost everything has been rewritten. The git diff for this version is
+  horrifying.
+
+- Formatting traits better leverage the builtin printing structures available
+  from `core::fmt`, and are made available on `no_std`.
+
+### Removed
+
+- `u64` is only usable as the storage type on 64-bit systems; it has 32-bit
+  alignment on 32-bit systems and as such is unusable there.
+
+## 0.9.0
+
+### Changed
+
+- The trait `Endian` has been renamed to `Cursor`, and all type variables
+  `E: Endian` have been renamed to `C: Cursor`.
+
+- The `Bits` trait is no longer bound by `Default`.
+
+## 0.8.0
+
+### Added
+
+- `std` and `alloc` features, which can be disabled for use in `#![no_std]`
+  libraries. This was implemented by Robert Habermeier, `rphmeier@gmail.com`.
+
+  Note that the `BitSlice` tests and all the examples are disabled when the
+  `alloc` feature is not present. They will function normally when `alloc` is
+  present but `std` is not.
+
+### Changed
+
+- Compute `Bits::WIDTH` as `size_of::<Self>() * 8` instead of `1 << Bits::BITS`.
+
+## 0.7.0
+
+### Added
+
+- `examples/readme.rs` tracks the contents of the example code in `README.md`.
+  It will continue to do so until the `external_doc` feature stabilizes so that
+  the contents of the README can be included in the module documentation of
+  `src/lib.rs`.
+
+- Officially use the Rust community code of conduct.
+
+- README sections describe why a user might want this library, and what makes it
+  different than `bit-vec`.
+
+### Changed
+
+- Update minimum Rust version to `1.30.0`.
+
+  Internally, this permits use of `std` rather than `::std`. This compiler
+  edition does not change *intra-crate* macro usage. Clients at `1.30.0` and
+  above no longer need `#[macro_use]` above `extern crate bitvec;`, and are able
+  to import the `bitvec!` macro directly with `use bitvec::bitvec;` or
+  `use bitvec::prelude::*`.
+
+  Implementation note: References to literals stabilized at *some* point between
+  `1.20.0` and `1.30.0`, so the static bool items used for indexing are no
+  longer needed.
+
+- Include numeric arithmetic as well as set arithmetic in the README.
+
+## 0.6.0
+
+### Changed
+
+- Update minimum Rust version to `1.25.0` in order to use nested imports.
+- Fix logic in `Endian::prev`, and re-enabled edge tests.
+- Pluralize `BitSlice::count_one()` and `BitSlice::count_zero()` function names.
+- Fix documentation and comments.
+- Consolidate implementation of `bitvec!` to not use any other macros.
+
+## 0.5.0
+
+### Added
+
+- `BitVec` and `BitSlice` implement `Hash`.
+
+- `BitVec` fully implements addition, negation, and subtraction.
+
+- `BitSlice` implements in-place addition and negation.
+  - `impl AddAssign for BitSlice`
+  - `impl Neg for &mut BitSlice`
+
+  This distinction is required in order to match the expectations of the
+  arithmetic traits and the realities of immovable `BitSlice`.
+
+- `BitSlice` offers `.all()`, `.any()`, `.not_all()`, `.not_any()`, and
+  `.some()` methods to perform n-ary Boolean logic.
+  - `.all()` tests if all bits are set high
+  - `.any()` tests if any bits are set high (includes `.all()`)
+  - `.not_all()` tests if any bits are set low (includes `.not_all()`)
+  - `.not_any()` tests if all bits are set low
+  - `.some()` tests if any bits are high and any are low (excludes `.all()` and
+    `.not_all()`)
+
+- `BitSlice` can count how many bits are set high or low with `.count_one()` and
+  `.count_zero()`.
+
+## 0.4.0
+
+### Added
+
+`BitSlice::for_each` provides mutable iteration over a slice. It yields each
+successive `(index: usize, bit: bool)` pair to a closure, and stores the return
+value of that closure at the yielded index.
+
+`BitVec` now implements `Eq` and `Ord` against other `BitVec`s. It is impossible
+at this time to make `BitVec` generic over anything that is `Borrow<BitSlice>`,
+which would allow comparisons over different ownership types. The declaration
+
+```rust
+impl<A, B, C, D, E> PartialEq<C> for BitVec<A, B>
+where A: Endian,
+    B: Bits,
+    C: Borrow<BitSlice<D, E>>,
+    D: Endian,
+    E: Bits,
+{
+    fn eq(&self, rhs: E) { … }
+}
+```
+
+is impossible to write, so `BitVec == BitSlice` will be rejected.
+
+As with many other traits on `BitVec`, the implementations are just a thin
+wrapper over the corresponding `BitSlice` implementations.
+
+### Changed
+
+Refine the API documentation. Rust guidelines recommend imperative rather than
+descriptive summaries for function documentation, which largely meant stripping
+the trailing -s from the first verb in each function document.
+
+I also moved the example code from the trait-level documentation to the
+function-level documentation, so that it would show up an `type::func` in the
+`rustdoc` output rather than just `type`. This makes it much clearer what is
+being tested.
+
+### Removed
+
+`BitVec` methods `iter` and `raw_len` moved to `BitSlice` in `0.3.0` but were
+not removed in that release.
+
+The remaining debugging `eprintln!` calls have been stripped.
+
+## 0.3.0
+
+Split `BitVec` off into `BitSlice` wherever possible.
+
+### Added
+
+- The `BitSlice` type is the `[T]` to `BitVec`'s `Vec<T>`. `BitVec` now `Deref`s
+  to it, and has offloaded all the work that does not require managing allocated
+  memory.
+- Almost all of the public API on both types has documentation and example code.
+
+### Changed
+
+- The implementations of left- ard right- shift are now faster.
+- `BitVec` can `Borrow` and `Deref` down to `BitSlice`, and offloads as much
+  work as possible to it.
+- `Clone` is more intelligent.
+
+## 0.2.0
+
+Improved the `bitvec!` macro.
+
+### Changed
+
+- `bitvec!` takes more syntaxes to better match `vec!`, and has better
+  runtime performance. The increased static memory used by `bitvec!` should be
+  more than counterbalanced by the vastly better generated code.
+
+## 0.1.0
+
+Initial implementation and release.
+
+### Added
+
+- `Endian` and `Bits` traits
+- `BitVec` type with basic `Vec` idioms and parallel trait implementations
+- `bitvec!` generator macro
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/CODE_OF_CONDUCT.md
@@ -0,0 +1,5 @@
+# Code of Conduct
+
+See the official [Rust code of conduct][coc].
+
+[coc]: https://www.rust-lang.org/policies/code-of-conduct
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/CONTRIBUTING.md
@@ -0,0 +1,45 @@
+# Contributing Guide
+
+Contributions are absolutely welcome!
+
+## Contact Information
+
+In order of likelihood that I will actionably receive your contact, my
+information is:
+
+- [appayne@outlook.com](mailto:appayne@outlook.com)
+- [@myrrlyn](//github.com/myrrlyn)
+- [@myrrlyn](//twitter.com/myrrlyn)
+- [@myrrlyn@cybre.space](//cybre.space/myrrlyn)
+- [/u/myrrlyn](//reddit.com/u/myrrlyn)
+
+I am not active on any IRC channels at this time. I am on Discord in the Rust
+channel, so you may be able to reach me there, but I don’t know offhand how to
+give out Discord profile links. I have a very consistent username scheme and so
+anywhere you see my name, it’s *probably* me and I’ll *probably* respond to it.
+
+## Preconditions
+
+Be able to make a Rust project compile. I will happily help you learn how to do
+this, but this particular crate is probably not something you want to explore as
+a beginner.
+
+Be comfortable using `U+0009 CHARACTER TABULATION` as your indentation setting.
+
+That’s about it for prerequisites! This crate intends to power the lowest-level
+of memory manipulation while also offering a convenient, powerful, and idiomatic
+high-level API, so I encourage and welcome inputs on any aspect of this crate’s
+construction. I know that I personally am much more capable at the low end than
+the high, and so the user-facing API may not be as strong as it should be.
+
+## Contributing
+
+If you have a patch you think is worth inspecting right away, opening a pull
+request without prelude is fine, although I would certainly appreciate an
+accompanying explanation of what the patch does and why.
+
+If you have questions, bugs, suggestions, or other contributions of any kind
+that do not immediately touch the codebase, you can reach me informally to talk
+about them or open an issue.
+
+I will do my best to respond to all contacts in a timely manner.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/Cargo.toml
@@ -0,0 +1,71 @@
+[package]
+name = "bitvec"
+version = "0.11.0"
+authors = [
+	"myrrlyn <self@myrrlyn.dev>",
+]
+categories = [
+	"data-structures",
+	"embedded",
+	"no-std",
+	"rust-patterns",
+]
+description = "A crate for manipulating memory, bit by bit"
+documentation = "https://docs.rs/bitvec"
+edition = "2018"
+homepage = "https://myrrlyn.net/bitvec"
+keywords = [
+	"bits",
+	"bitvec",
+]
+license = "MIT"
+readme = "README.md"
+repository = "https://github.com/myrrlyn/bitvec"
+
+[features]
+alloc = []
+default = [
+	"std",
+]
+serdes = [
+	"serde",
+]
+std = [
+	"alloc",
+]
+testing = [
+	"std",
+]
+
+[dependencies.serde]
+default-features = false
+features = [
+	"derive",
+]
+optional = true
+version = "1"
+
+[dev-dependencies]
+serde = "1"
+serde_json = "1"
+serde_test = "1"
+
+[package.metadata.docs.rs]
+features = [
+	"serdes",
+	"std",
+]
+
+[badges.codecov]
+repository = "myrrlyn/bitvec"
+branch = "master"
+service = "github"
+
+[badges.is-it-maintained-issue-resolution]
+repository = "myrrlyn/bitvec"
+
+[badges.is-it-maintained-open-issues]
+repository = "myrrlyn/bitvec"
+
+[badges.maintenance]
+status = "actively-developed"
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/Justfile
@@ -0,0 +1,59 @@
+################################################################################
+#                                   Justfile                                   #
+#                                                                              #
+# Set of routines to execute for development work. As of 2019-03-31, `just`    #
+# does not work on Windows.                                                    #
+################################################################################
+
+# Cargo features
+features = "serdes,std,testing"
+
+# Builds the library.
+build:
+	cargo build --features {{features}}
+	cargo build --features {{features}} --example sieve
+	cargo build --features {{features}} --example tour
+	cargo build --features {{features}} --example serdes
+	cargo build --features {{features}} --example readme
+
+# Checks the library for syntax and HIR errors.
+check:
+	cargo check --features {{features}}
+
+# Runs all of the recipes necessary for pre-publish.
+checkout: check clippy build doc test package
+
+# Continually runs the development routines.
+ci:
+	just loop dev
+
+# Removes all build artifacts.
+clean:
+	cargo clean
+
+# Runs clippy.
+clippy: check
+	cargo clippy --features {{features}}
+
+# Runs the development routines.
+dev: clippy doc test
+
+# Builds the crate documentation.
+doc:
+	cargo doc --features {{features}} --document-private-items
+
+# Continually runs some recipe from this file.
+loop action:
+	cargo watch -s "just {{action}}"
+
+# Packages the crate in preparation for publishing on crates.io
+package:
+	cargo package --allow-dirty
+
+# Publishes the crate to crates.io
+publish: checkout
+	cargo publish
+
+# Runs the test suites.
+test: check
+	cargo test --features {{features}}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 myrrlyn (Alexander Payne)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/README.md
@@ -0,0 +1,243 @@
+# `BitVec` – Managing memory bit by bit
+
+[![Crate][crate_img]][crate]
+[![Documentation][docs_img]][docs]
+[![License][license_img]][license_file]
+[![Continuous Integration][travis_img]][travis]
+[![Code Coverage][codecov_img]][codecov]
+[![Crate Downloads][downloads_img]][crate]
+
+This crate provides packed bit-level analogues to `[T]` and `Vec<T>`. The slice
+type `BitSlice` and the vector type `BitVec` allow bitwise access to a region of
+memory in any endian ordering or underlying primitive type. This permits
+construction of space-efficient sets or fine-grained control over the values in
+a region of memory.
+
+`BitVec` is a strict expansion of `BitSlice` to include allocation management.
+Since `BitVec` is shorter to type, the rest of this document will use it by
+default, and mark out sections that apply *only* to the vector type and not to
+the slice type. Unless marked, assume that the text applies to both.
+
+`BitVec` is generic over an ordering cursor, using the trait `Cursor`, and the
+primitive type, using the trait `Bits`. This means that `BitVec` structures can
+be built with a great deal of flexibility over how they manage their memory and
+translate between the in-memory representation and their semantic contents.
+
+`BitVec` acts as closely to a standard `Vec` as possible, and can be assumed by
+default to be what a `Vec<u1>` would be if such a type were possible to express
+in Rust. It has stack semantics, in that push and pop operations take place only
+on one end of the `BitVec`’s buffer. It supports iteration, bitwise operations,
+and rendering for `Display` and `Debug`.
+
+## How Is This Different Than the `bit_vec` Crate
+
+- It is more recently actively maintained (I may, in the future as of this
+  writing, let it lapse)
+- It doesn’t have a hyphen in the name, so you don’t have to deal with the
+  hyphen/underscore dichotomy.
+- My `BitVec` structure is exactly the size of a `Vec`; theirs is larger.
+- I have a `BitSlice` borrowed view.
+- My types implement all of the standard library’s slice and vector APIs
+
+## Why Would You Use This
+
+- You need to directly control a bitstream’s representation in memory.
+- You need to do unpleasant things with communications protocols.
+- You need a list of `bool`s that doesn’t waste 7 bits for every bit used.
+- You need to do set arithmetic, or numeric arithmetic, on those lists.
+
+## Usage
+
+**Minimum Rust Version**: `1.31.0`
+
+I wrote this crate because I was unhappy with the other bit-vector crates
+available. I specifically need to manage raw memory in bit-level precision, and
+this is not a behavior pattern the other bit-vector crates made easily available
+to me. This served as the guiding star for my development process on this crate,
+and remains the crate’s primary goal.
+
+To this end, the default type parameters for the `BitVec` type use `u8` as the
+storage primitive and use big-endian ordering of bits: the forwards direction is
+from MSb to LSb, and the backwards direction is from LSb to MSb.
+
+To use this crate, you need to depend on it in `Cargo.toml`:
+
+```toml
+[dependencies]
+bitvec = "0.11"
+```
+
+and include it in your crate root `src/main.rs` or `src/lib.rs`:
+
+```rust,no-run
+extern crate bitvec;
+
+use bitvec::prelude::*;
+```
+
+This imports the following symbols:
+
+- `bitvec!` – a macro similar to `vec!`, which allows the creation of `BitVec`s
+  of any desired endianness, storage type, and contents. The documentation page
+  has a detailed explanation of its syntax.
+
+- `BitSlice<C: Cursor, T: Bits>` – the actual bit-slice reference type. It is
+  generic over a cursor type (`C`) and storage type (`T`). Note that `BitSlice`
+  is unsized, and can never be held directly; it must always be behind a
+  reference such as `&BitSlice` or `&mut BitSlice`.
+
+  Furthermore, it is *impossible* to put `BitSlice` into any kind of intelligent
+  pointer such as a `Box` or `Rc`! Any work that involves managing the memory
+  behind a bitwise type *must* go through `BitBox` or `BitVec` instead. This may
+  change in the future as I learn how to better manage this library, but for now
+  this limitation stands.
+
+- `BitVec<C: Cursor, T: Bits>` – the actual bit-vector structure type. It is
+  generic over a cursor type (`C`) and storage type (`T`).
+
+- `Cursor` – an open trait that defines an ordering schema for `BitVec` to use.
+  Little and big endian orderings are provided by default. If you wish to
+  implement other ordering types, the `Cursor` trait requires one function:
+
+  - `fn at<T: Bits>(index: u8) -> u8` takes a semantic index and computes a bit
+    offset into the primitive `T` for it.
+
+- `BigEndian` – a zero-sized struct that implements `Cursor` by defining the
+  forward direction as towards LSb and the backward direction as towards MSb.
+
+- `LittleEndian` – a zero-sized struct that implements `Cursor` by defining the
+  forward direction as towards MSb and the backward direction as towards LSb.
+
+- `Bits` – a sealed trait that provides generic access to the four Rust
+  primitives usable as storage types: `u8`, `u16`, `u32`, and `u64`. `usize`
+  and the signed integers do *not* implement `Bits` and cannot be used as the
+  storage type. `u128` also does not implement `Bits`, as I am not confident in
+  its memory representation.
+
+`BitVec` has the same API as `Vec`, and should be easy to use.
+
+The `bitvec!` macro requires type information as its first two arguments.
+Because macros do not have access to the type checker, this currently only
+accepts the literal tokens `BigEndian` or `LittleEndian` as the first argument,
+one of the four unsigned integer primitives as the second argument, and then as
+many values as you wish to insert into the `BitVec`. It accepts any integer
+value, and maps them to bits by comparing against 0. `0` becomes `0` and any
+other integer, whether it is odd or not, becomes `1`. While the syntax is loose,
+you should only use `0` and `1` to fill the macro, for readability and lack of
+surprise.
+
+### `no_std`
+
+This crate can be used in `#![no_std]` libraries, by disabling the default
+feature set. In your `Cargo.toml`, write:
+
+```toml
+[dependencies]
+bitvec = { version = "0.11", default-features = false }
+```
+
+or
+
+```toml
+[dependencies.bitvec]
+version = "0.11"
+default-features = false
+```
+
+This turns off the standard library imports *and* all usage of dynamic memory
+allocation. Without an allocator, the `bitvec!` macro and the `BitVec` type are
+both disable and removed from the library, leaving only the `BitSlice` type.
+
+To use `bitvec` in a `#![no_std]` environment that *does* have an allocator,
+re-enable the `alloc` feature, like so:
+
+```toml
+[dependencies.bitvec]
+version = "0.11"
+default-features = false
+features = ["alloc"]
+```
+
+The `alloc` feature restores `bitvec!` and `BitVec`, as well as the `BitSlice`
+interoperability with `BitVec`. The only difference between `alloc` and `std` is
+the presence of the standard library façade and runtime support.
+
+The `std` feature turns on `alloc`, so using this crate without any feature
+flags *or* by explicitly enabling the `std` feature will enable full
+functionality.
+
+## Example
+
+```rust
+extern crate bitvec;
+
+use bitvec::prelude::*;
+
+use std::iter::repeat;
+
+fn main() {
+    let mut bv = bitvec![BigEndian, u8; 0, 1, 0, 1];
+    bv.reserve(8);
+    bv.extend(repeat(false).take(4).chain(repeat(true).take(4)));
+
+    //  Memory access
+    assert_eq!(bv.as_slice(), &[0b0101_0000, 0b1111_0000]);
+    //                 index 0 -^               ^- index 11
+    assert_eq!(bv.len(), 12);
+    assert!(bv.capacity() >= 16);
+
+    //  Set operations
+    bv &= repeat(true);
+    bv = bv | repeat(false);
+    bv ^= repeat(true);
+    bv = !bv;
+
+    //  Arithmetic operations
+    let one = bitvec![1];
+    bv += one.clone();
+    assert_eq!(bv.as_slice(), &[0b0101_0001, 0b0000_0000]);
+    bv -= one.clone();
+    assert_eq!(bv.as_slice(), &[0b0101_0000, 0b1111_0000]);
+
+    //  Borrowing iteration
+    let mut iter = bv.iter();
+    //  index 0
+    assert_eq!(iter.next().unwrap(), false);
+    //  index 11
+    assert_eq!(iter.next_back().unwrap(), true);
+    assert_eq!(iter.len(), 10);
+}
+```
+
+Immutable and mutable access to the underlying memory is provided by the `AsRef`
+and `AsMut` implementations, so the `BitVec` can be readily passed to transport
+functions.
+
+`BitVec` implements `Borrow` down to `BitSlice`, and `BitSlice` implements
+`ToOwned` up to `BitVec`, so they can be used in a `Cow` or wherever this API
+is desired. Any case where a `Vec`/`[T]` pair cannot be replaced with a
+`BitVec`/`BitSlice` pair is a bug in this library, and a bug report is
+appropriate.
+
+`BitVec` can relinquish its owned memory as a `Box<[T]>` via the
+`.into_boxed_slice()` method, and `BitSlice` can relinquish access to its memory
+simply by going out of scope.
+
+## Planned Features
+
+Contributions of items in this list are *absolutely* welcome! Contributions of
+other features are also welcome, but I’ll have to be sold on them.
+
+- Creation of specialized pointers `Rc<BitSlice>` and `Arc<BitSlice>`.
+
+[codecov]: https://codecov.io/gh/myrrlyn/bitvec "Code Coverage"
+[codecov_img]: https://img.shields.io/codecov/c/github/myrrlyn/bitvec.svg?logo=codecov "Code Coverage Display"
+[crate]: https://crates.io/crates/bitvec "Crate Link"
+[crate_img]: https://img.shields.io/crates/v/bitvec.svg?logo=rust "Crate Page"
+[docs]: https://docs.rs/bitvec "Documentation"
+[docs_img]: https://docs.rs/bitvec/badge.svg "Documentation Display"
+[downloads_img]: https://img.shields.io/crates/dv/bitvec.svg?logo=rust "Crate Downloads"
+[license_file]: https://github.com/myrrlyn/bitvec/blob/master/LICENSE.txt "License File"
+[license_img]: https://img.shields.io/crates/l/bitvec.svg "License Display"
+[travis]: https://travis-ci.org/myrrlyn/bitvec "Travis CI"
+[travis_img]: https://img.shields.io/travis/myrrlyn/bitvec.svg?logo=travis "Travis CI Display"
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/doc/Bit Patterns.md	
@@ -0,0 +1,118 @@
+# Bit Patterns
+
+This table displays the *bit index*, in [base64], of each position in a
+`BitSlice<Cursor, Fundamental>` on a little-endian machine.
+
+```text
+byte  | 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777
+bit   | 76543210 76543210 76543210 76543210 76543210 76543210 76543210 76543210
+------+------------------------------------------------------------------------
+LEu__ | HGFEDCBA PONMLKJI XWVUTSRQ fedcbaZY nmlkjihg vutsrqpo 3210zyxw /+987654
+BEu64 | 456789+/ wxyz0123 opqrstuv ghijklmn YZabcdef QRSTUVWX IJKLMNOP ABCDEFGH
+BEu32 | YZabcdef QRSTUVWX IJKLMNOP ABCDEFGH 456789+/ wxyz0123 opqrstuv ghijklmn
+BEu16 | IJKLMNOP ABCDEFGH YZabcdef QRSTUVWX opqrstuv ghijklmn 456789+/ wxyz0123
+BEu8  | ABCDEFGH IJKLMNOP QRSTUVWX YZabcdef ghijklmn opqrstuv wxyz0123 456789+/
+```
+
+This table displays the bit index in [base64] of each position in a
+`BitSlice<Cursor, Fundamental>` on a big-endian machine.
+
+```text
+byte  | 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777
+bit   | 76543210 76543210 76543210 76543210 76543210 76543210 76543210 76543210
+------+------------------------------------------------------------------------
+BEu__ | ABCDEFGH IJKLMNOP QRSTUVWX YZabcdef ghijklmn opqrstuv wxyz0123 456789+/
+LEu64 | /+987654 3210zyxw vutsrqpo nmlkjihg fedcbaZY XWVUTSRQ PONMLKJI HGFEDCBA
+LEu32 | fedcbaZY XWVUTSRQ PONMLKJI HGFEDCBA /+987654 3210zyxw vutsrqpo nmlkjihg
+LEu16 | PONMLKJI HGFEDCBA fedcbaZY XWVUTSRQ vutsrqpo nmlkjihg /+987654 3210zyxw
+LEu8  | HGFEDCBA PONMLKJI XWVUTSRQ fedcbaZY nmlkjihg vutsrqpo 3210zyxw /+987654
+```
+
+`<BigEndian, u8>` and `<LittleEndian, u8>` will always have the same
+representation in memory on all machines. The wider cursors will not.
+
+# Pointer Representation
+
+Currently, the bitslice pointer uses the `len` field to address an individual
+bit in the slice. This means that all bitslices can address `usize::MAX` bits,
+regardless of the underlying storage fundamental. The bottom `3 <= n <= 6` bits
+of `len` address the bit in the fundamental, and the high bits address the
+fundamental in the slice.
+
+The next representation of bitslice pointer will permit the data pointer to
+address any *byte*, regardless of fundamental type, and address any bit in that
+byte by storing the bit position in `len`. This reduces the bit storage capacity
+of bitslice from `usize::MAX` to `usize::MAX / 8`. 2<sup>29</sup> is still a
+very large number, so I do not anticipate 32-bit machines being too limited by
+this.
+
+This means that bitslice pointers will have the following representation, in C++
+because Rust lacks bitfield syntax.
+
+```cpp
+template<typename T>
+struct WidePtr<T> {
+  size_t ptr_byte : __builtin_ctzll(alignof(T)); // 0 ... 3
+  size_t ptr_data : sizeof(T*) * 8
+                  - __builtin_ctzll(alignof(T)); // 64 ... 61
+
+  size_t len_head : 3;
+  size_t len_tail : 3 + __builtin_ctzll(alignof(T)); // 3 ... 6
+  size_t len_data : sizeof(size_t) * 8
+                  - 6 - __builtin_ctzll(alignof(T)); // 58 ... 55
+};
+```
+
+So, for any storage fundamental, its bitslice pointer representation has:
+
+- the low `alignof` bits of the pointer for selecting a byte, and the rest of
+  the pointer for selecting the fundamental. This is just a `*const u8` except
+  the type remembers how to find the correctly aligned pointer.
+
+- the lowest 3 bits of the length counter for selecting the bit under the head
+  pointer
+- the *next* (3 + log<sub>2</sub>(bit size)) bits of the length counter address
+  the final bit within the final *storage fundamental* of the slice.
+- the remaining high bits address the final *storage fundamental* of the slice,
+  counting from the correctly aligned address in the pointer.
+
+# Calculations
+
+Given an arbitrary `WidePtr<T>` value,
+
+- the initial `*const T` pointer is retrieved by masking away the low bits of
+  the `ptr` value
+
+- the number of `T` elements *between* the first and the last is found by taking
+  the `len` value, masking away the low bits, and shifting right/down.
+
+- the number of `T` elements in the slice is found by taking the above and
+  adding one
+
+- the address of the last `T` element in the slice is found by taking the
+  initial pointer, and adding the `T`-element-count to it
+
+- the slot number of the first live bit in the slice is found by masking away
+  the high bits of `ptr` and shifting the result left/up by three, then adding
+  the low three bits of `len`
+
+# Values
+
+## Uninhabited Domains
+
+All pointers whose non-`data` members are fully zeroed are considered
+uninhabited. When the `data` member is the null pointer, then the slice is
+*empty*; when it is non-null, the slice points to a validly allocated region of
+memory and is merely uninhabited. This distinction is important for vectors.
+
+## Full Domains
+
+The longest possible domain has `!0` as its `elts`, and `tail` values, and `0`
+as its `head` value.
+
+When `elts` and `tail` are both `!0`, then the `!0`th element has `!0 - 1` live
+bits. The final bit in the final element is a tombstone that cannot be used.
+This is a regrettable consequence of the need to distinguish between the nil and
+uninhabited slices.
+
+[base64]: https://en.wikipedia.org/wiki/Base64
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/examples/readme.rs
@@ -0,0 +1,50 @@
+/*! Prove that the example code in `README.md` executes.
+!*/
+
+#[cfg(feature = "alloc")]
+extern crate bitvec;
+
+#[cfg(feature = "alloc")]
+use bitvec::prelude::*;
+
+#[cfg(feature = "alloc")]
+use std::iter::repeat;
+
+#[cfg(feature = "alloc")]
+fn main() {
+    let mut bv = bitvec![BigEndian, u8; 0, 1, 0, 1];
+    bv.reserve(8);
+    bv.extend(repeat(false).take(4).chain(repeat(true).take(4)));
+
+    //  Memory access
+    assert_eq!(bv.as_slice(), &[0b0101_0000, 0b1111_0000]);
+    //                 index 0 -^               ^- index 11
+    assert_eq!(bv.len(), 12);
+    assert!(bv.capacity() >= 16);
+
+    //  Set operations
+    bv &= repeat(true);
+    bv = bv | repeat(false);
+    bv ^= repeat(true);
+    bv = !bv;
+
+    //  Arithmetic operations
+    let one = bitvec![1];
+    bv += one.clone();
+    assert_eq!(bv.as_slice(), &[0b0101_0001, 0b0000_0000]);
+    bv -= one.clone();
+    assert_eq!(bv.as_slice(), &[0b0101_0000, 0b1111_0000]);
+
+    //  Borrowing iteration
+    let mut iter = bv.iter();
+    //  index 0
+    assert_eq!(iter.next().unwrap(), false);
+    //  index 11
+    assert_eq!(iter.next_back().unwrap(), true);
+    assert_eq!(iter.len(), 10);
+}
+
+#[cfg(not(feature = "alloc"))]
+fn main() {
+	println!("This example only runs when an allocator is present");
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/examples/serdes.rs
@@ -0,0 +1,27 @@
+/*! This example shows off de/serializing a bit sequence using serde.
+
+The example uses JSON for simplicity of demonstration; it should work with all
+serde-compatible de/ser protocols.
+!*/
+
+extern crate bitvec;
+extern crate serde;
+extern crate serde_json;
+
+use bitvec::prelude::*;
+
+#[cfg(all(feature = "alloc", feature = "serdes"))]
+fn main() {
+	let bv = bitvec![1, 0, 1, 1, 0, 0, 1, 0];
+	let json = serde_json::to_string(&bv).expect("cannot fail to serialize");
+	assert_eq!(json.trim(),r#"{"elts":1,"head":0,"tail":8,"data":[178]}"#);
+
+	let bb: BitBox = serde_json::from_str(&json).expect("cannot fail to deserialize");
+	assert!(bb[0]);
+	assert_eq!(bb.as_slice()[0], 178);
+}
+
+#[cfg(not(all(feature = "alloc", feature = "serdes")))]
+fn main() {
+	println!("This test needs to be compiled with `--features serdes` to work");
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/examples/sieve.rs
@@ -0,0 +1,125 @@
+/*! Sieve of Eratosthenes
+
+The `bit_vec` crate had this as an example, so I do too, I guess.
+
+Run with
+
+```sh
+$ cargo run --release --example sieve -- [max] [count]
+```
+
+where max is an optional maximum number below which all primes will be found,
+and count is an optional number whose square will be used to display the bottom
+primes.
+
+For example,
+
+```sh
+$ cargo run --release --example sieve -- 10000000 25
+```
+
+will find all primes less than ten million, and print the primes below 625 in a
+square 25x25.
+!*/
+
+#[cfg(feature = "alloc")]
+extern crate bitvec;
+
+#[cfg(feature = "alloc")]
+use bitvec::prelude::{
+	BitVec,
+	BigEndian,
+};
+#[cfg(feature = "alloc")]
+use std::env;
+
+#[cfg(feature = "alloc")]
+fn main() {
+	let max_prime: usize = env::args()
+		.nth(1)
+		.unwrap_or("1000000".into())
+		.parse()
+		.unwrap_or(1_000_000);
+
+	let primes = {
+		let mut bv = BitVec::<BigEndian, u64>::with_capacity(max_prime);
+		bv.set_elements(!0u64);
+
+		//  Consider the vector fully populated
+		unsafe { bv.set_len(max_prime); }
+
+		//  0 and 1 are not primes
+		bv.set(0, false);
+		bv.set(1, false);
+
+		for n in 2 .. (1 + (max_prime as f64).sqrt() as usize) {
+			//  Adjust the frequency of log statements vaguely logarithmically.
+			if n <  20_000 && n %  1_000 == 0
+			|| n <  50_000 && n %  5_000 == 0
+			|| n < 100_000 && n % 10_000 == 0 {
+				println!("Calculating {}…", n);
+			}
+			//  If n is prime, mark all multiples as non-prime
+			if bv[n] {
+				if n < 50 {
+					println!("Calculating {}…", n);
+				}
+				'inner:
+				for i in n .. {
+					let j = n * i;
+					if j >= max_prime {
+						break 'inner;
+					}
+					bv.set(j, false);
+				}
+			}
+		}
+		println!("Calculation complete!");
+
+		bv
+	};
+
+	//  Count primes and non-primes.
+	let (mut one, mut zero) = (0u64, 0u64);
+	for n in primes.iter() {
+		if n {
+			one += 1;
+		}
+		else {
+			zero += 1;
+		}
+	}
+	println!("Counting complete!");
+	println!("There are {} primes and {} non-primes below {}", one, zero, max_prime);
+
+	let dim: usize = env::args()
+		.nth(2)
+		.unwrap_or("10".into())
+		.parse()
+		.unwrap_or(10);
+
+	println!("The primes smaller than {} are:", dim * dim);
+	let len = primes.len();
+	'outer:
+	for i in 0 .. dim {
+		for j in 0 .. dim {
+			let k = i * dim + j;
+			if k >= len {
+				println!();
+				break 'outer;
+			}
+			if primes[k] {
+				print!("{:>4} ", k);
+			}
+			else {
+				print!("     ");
+			}
+		}
+		println!();
+	}
+}
+
+#[cfg(not(feature = "alloc"))]
+fn main() {
+	println!("This example only runs when an allocator is present");
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/examples/tour.rs
@@ -0,0 +1,113 @@
+/*! Demonstrates construction and use of a big-endian, u8, `BitVec`
+
+This example uses `bitvec!` to construct a `BitVec` from literals, then shows
+a sample of the various operations that can be applied to it.
+
+This example prints **a lot** of text to the console.
+!*/
+
+#[cfg(feature = "alloc")]
+extern crate bitvec;
+
+#[cfg(feature = "alloc")]
+use bitvec::prelude::{
+	//  `bitvec!` macro
+	bitvec,
+	//  trait unifying the primitives (you shouldn’t explicitly need this)
+	Bits,
+	//  primary type of the whole crate! this is where the magic happens
+	BitVec,
+	//  element-traversal trait (you shouldn’t explicitly need this)
+	Cursor,
+	//  directionality type marker (the default for `BitVec`; you will rarely
+	//  explicitly need this)
+	BigEndian,
+	//  directionality type marker (you will explicitly need this if you want
+	//  this ordering)
+	LittleEndian,
+};
+#[cfg(feature = "alloc")]
+use std::iter::repeat;
+
+#[cfg(feature = "alloc")]
+fn main() {
+	let bv = bitvec![   //  BigEndian, u8;  //  default type values
+		0, 0, 0, 0, 0, 0, 0, 1,
+		0, 0, 0, 0, 0, 0, 1, 0,
+		0, 0, 0, 0, 0, 1, 0, 0,
+		0, 0, 0, 0, 1, 0, 0, 0,
+		0, 0, 0, 1, 0, 0, 0, 0,
+		0, 0, 1, 0, 0, 0, 0, 0,
+		0, 1, 0, 0, 0, 0, 0, 0,
+		1, 0, 0, 0, 0, 0, 0, 0,
+		1, 0, 0, 0, 0, 0, 0, 0,
+		0, 1, 0, 0, 0, 0, 0, 0,
+		0, 0, 1, 0, 0, 0, 0, 0,
+		0, 0, 0, 1, 0, 0, 0, 0,
+		0, 0, 0, 0, 1, 0, 0, 0,
+		0, 0, 0, 0, 0, 1, 0, 0,
+		0, 0, 0, 0, 0, 0, 1, 0,
+		0, 0, 0, 0, 0, 0, 0, 1,
+		1, 0, 1, 0,
+	];
+	println!("A BigEndian BitVec has the same layout in memory as it does \
+		semantically");
+	render(&bv);
+
+	//  BitVec can turn into iterators, and be built from iterators.
+	let bv: BitVec<LittleEndian, u8> = bv.into_iter().collect();
+	println!("A LittleEndian BitVec has the opposite layout in memory as it \
+		does semantically");
+	render(&bv);
+
+	let bv: BitVec<BigEndian, u16> = bv.into_iter().collect();
+	println!("A BitVec can use storage other than u8");
+	render(&bv);
+
+	println!("BitVec can participate in Boolean arithmetic");
+	let full = bv.clone() | repeat(true);
+	render(&full);
+	let empty = full & repeat(false);
+	render(&empty);
+	let flip = bv ^ repeat(true);
+	render(&flip);
+	let bv = !flip;
+	render(&bv);
+
+	println!("\
+Notice that `^` did not affect the parts of the tail that were not in
+use, while `!` did affect them. `^` requires a second source, while `!`
+can just flip all elements. `!` is faster, but `^` is less likely to
+break your assumptions about what the memory looks like.\
+	");
+
+	//  Push and pop to the bitvec
+	let mut bv = bv;
+	for _ in 0 .. 12 {
+		bv.push(false);
+	}
+	for _ in 0 .. 12 {
+		bv.pop();
+	}
+	render(&bv);
+
+	println!("End example");
+
+	fn render<C: Cursor, T: Bits>(bv: &BitVec<C, T>) {
+		println!("Memory information: {} elements, {}", bv.as_slice().len(), bv.len());
+		println!("Print out the semantic contents");
+		println!("{:#?}", bv);
+		println!("Print out the memory contents");
+		println!("{:?}", bv.as_slice());
+		println!("Show the bits in memory");
+		for elt in bv.as_slice() {
+			println!("{:0w$b} ", elt, w=std::mem::size_of::<T>() * 8);
+		}
+		println!();
+	}
+}
+
+#[cfg(not(feature = "alloc"))]
+fn main() {
+	println!("This example only runs when an allocator is present");
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/bits.rs
@@ -0,0 +1,815 @@
+/*! Bit Management
+
+The `Bits` trait defines constants and free functions suitable for managing bit
+storage of a fundamental, and is the constraint for the storage type of the data
+structures of the rest of the crate.
+!*/
+
+use crate::cursor::Cursor;
+use core::{
+	cmp::Eq,
+	convert::From,
+	fmt::{
+		self,
+		Binary,
+		Debug,
+		Display,
+		Formatter,
+		LowerHex,
+		UpperHex,
+	},
+	mem::size_of,
+	ops::{
+		BitAnd,
+		BitAndAssign,
+		BitOrAssign,
+		Deref,
+		DerefMut,
+		Not,
+		Shl,
+		ShlAssign,
+		Shr,
+		ShrAssign,
+	},
+};
+
+/** Generalizes over the fundamental types for use in `bitvec` data structures.
+
+This trait must only be implemented on unsigned integer primitives with full
+alignment. It cannot be implemented on `u128` on any architecture, or on `u64`
+on 32-bit systems.
+
+The `Sealed` supertrait ensures that this can only be implemented locally, and
+will never be implemented by downstream crates on new types.
+**/
+pub trait Bits:
+	//  Forbid external implementation
+	Sealed
+	+ Binary
+	//  Element-wise binary manipulation
+	+ BitAnd<Self, Output=Self>
+	+ BitAndAssign<Self>
+	+ BitOrAssign<Self>
+	//  Permit indexing into a generic array
+	+ Copy
+	+ Debug
+	+ Display
+	//  Permit testing a value against 1 in `get()`.
+	+ Eq
+	//  Rust treats numeric literals in code as vaguely typed and does not make
+	//  them concrete until long after trait expansion, so this enables building
+	//  a concrete Self value from a numeric literal.
+	+ From<u8>
+	//  Permit extending into a `u64`.
+	+ Into<u64>
+	+ LowerHex
+	+ Not<Output=Self>
+	+ Shl<u8, Output=Self>
+	+ ShlAssign<u8>
+	+ Shr<u8, Output=Self>
+	+ ShrAssign<u8>
+	//  Allow direct access to a concrete implementor type.
+	+ Sized
+	+ UpperHex
+{
+	/// The size, in bits, of this type.
+	const SIZE: u8 = size_of::<Self>() as u8 * 8;
+
+	/// The number of bits required to index the type. This is always
+	/// log<sub>2</sub> of the type’s bit size.
+	const BITS: u8 = Self::SIZE.trailing_zeros() as u8;
+
+	/// The bitmask to turn an arbitrary `usize` into a bit index. Bit indices
+	/// are always stored in the lowest bits of an index value.
+	const MASK: u8 = Self::SIZE - 1;
+
+	/// Name of the implementing type.
+	const TYPENAME: &'static str;
+
+	/// Sets a specific bit in an element to a given value.
+	///
+	/// # Parameters
+	///
+	/// - `place`: A bit index in the element, from `0` to `Self::MASK`. The bit
+	///   under this index will be set according to `value`.
+	/// - `value`: A Boolean value, which sets the bit on `true` and unsets it
+	///   on `false`.
+	///
+	/// # Type Parameters
+	///
+	/// - `C: Cursor`: A `Cursor` implementation to translate the index into a
+	///   position.
+	///
+	/// # Panics
+	///
+	/// This function panics if `place` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example sets and unsets bits in a byte.
+	///
+	/// ```rust
+	/// use bitvec::prelude::{Bits, BigEndian};
+	/// let mut elt: u8 = 0;
+	/// elt.set::<BigEndian>(0.into(), true);
+	/// assert_eq!(elt, 0b1000_0000);
+	/// elt.set::<BigEndian>(4.into(), true);
+	/// assert_eq!(elt, 0b1000_1000);
+	/// elt.set::<BigEndian>(0.into(), false);
+	/// assert_eq!(elt, 0b0000_1000);
+	/// ```
+	///
+	/// This example overruns the index, and panics.
+	///
+	/// ```rust,should_panic
+	/// use bitvec::prelude::{Bits, BigEndian};
+	/// let mut elt: u8 = 0;
+	/// elt.set::<BigEndian>(8.into(), true);
+	/// ```
+	fn set<C: Cursor>(&mut self, place: BitIdx, value: bool) {
+		self.set_at(C::at::<Self>(place), value)
+	}
+
+	/// Sets a specific bit in an element to a given value.
+	///
+	/// # Parameters
+	///
+	/// - `place`: A bit *position* in the element, where `0` is the LSbit and
+	///   `Self::MASK` is the MSbit.
+	/// - `value`: A Boolean value, which sets the bit high on `true` and unsets
+	///   it low on `false`.
+	///
+	/// # Panics
+	///
+	/// This function panics if `place` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example sets and unsets bits in a byte.
+	///
+	/// ```rust
+	/// use bitvec::bits::Bits;
+	/// let mut elt: u8 = 0;
+	/// elt.set_at(0.into(), true);
+	/// assert_eq!(elt, 0b0000_0001);
+	/// elt.set_at(7.into(), true);
+	/// assert_eq!(elt, 0b1000_0001);
+	/// ```
+	///
+	/// This example overshoots the width, and panics.
+	///
+	/// ```rust,should_panic
+	/// use bitvec::bits::Bits;
+	/// let mut elt: u8 = 0;
+	/// elt.set_at(8.into(), true);
+	/// ```
+	fn set_at(&mut self, place: BitPos, value: bool) {
+		assert!(
+			*place < Self::SIZE,
+			"Index out of range: {} overflows {}",
+			*place,
+			Self::SIZE,
+		);
+		//  Blank the selected bit
+		*self &= !(Self::from(1u8) << *place);
+		//  Set the selected bit
+		*self |= Self::from(value as u8) << *place;
+	}
+
+	/// Gets a specific bit in an element.
+	///
+	/// # Parameters
+	///
+	/// - `place`: A bit index in the element, from `0` to `Self::MASK`. The bit
+	///   under this index will be retrieved as a `bool`.
+	///
+	/// # Returns
+	///
+	/// The value of the bit under `place`, as a `bool`.
+	///
+	/// # Type Parameters
+	///
+	/// - `C: Cursor`: A `Cursor` implementation to translate the index into a
+	///   position.
+	///
+	/// # Panics
+	///
+	/// This function panics if `place` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example gets two bits from a byte.
+	///
+	/// ```rust
+	/// use bitvec::prelude::{Bits, BigEndian};
+	/// let elt: u8 = 0b0010_0000;
+	/// assert!(!elt.get::<BigEndian>(1.into()));
+	/// assert!(elt.get::<BigEndian>(2.into()));
+	/// assert!(!elt.get::<BigEndian>(3.into()));
+	/// ```
+	///
+	/// This example overruns the index, and panics.
+	///
+	/// ```rust,should_panic
+	/// use bitvec::prelude::{Bits, BigEndian};
+	/// 0u8.get::<BigEndian>(8.into());
+	/// ```
+	fn get<C: Cursor>(&self, place: BitIdx) -> bool {
+		self.get_at(C::at::<Self>(place))
+	}
+
+	/// Gets a specific bit in an element.
+	///
+	/// # Parameters
+	///
+	/// - `place`: A bit *position* in the element, from `0` at LSbit to
+	///   `Self::MASK` at MSbit. The bit under this position will be retrieved
+	///   as a `bool`.
+	///
+	/// # Returns
+	///
+	/// The value of the bit under `place`, as a `bool`.
+	///
+	/// # Panics
+	///
+	/// This function panics if `place` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example gets two bits from a byte.
+	///
+	/// ```rust
+	/// use bitvec::bits::Bits;
+	/// let elt: u8 = 0b0010_0000;
+	/// assert!(!elt.get_at(4.into()));
+	/// assert!(elt.get_at(5.into()));
+	/// assert!(!elt.get_at(6.into()));
+	/// ```
+	///
+	/// This example overruns the index, and panics.
+	///
+	/// ```rust,should_panic
+	/// use bitvec::bits::Bits;
+	/// 0u8.get_at(8.into());
+	/// ```
+	fn get_at(&self, place: BitPos) -> bool {
+		assert!(
+			*place < Self::SIZE,
+			"Index out of range: {} overflows {}",
+			*place,
+			Self::SIZE,
+		);
+		//  Shift down so the targeted bit is in LSb, then blank all other bits.
+		(*self >> *place) & Self::from(1) == Self::from(1)
+	}
+
+	/// Counts how many bits in `self` are set to `1`.
+	///
+	/// This zero-extends `self` to `u64`, and uses the [`u64::count_ones`]
+	/// inherent method.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of bits in `self` set to `1`. This is a `usize` instead of a
+	/// `u32` in order to ease arithmetic throughout the crate.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::bits::Bits;
+	/// assert_eq!(Bits::count_ones(&0u8), 0);
+	/// assert_eq!(Bits::count_ones(&128u8), 1);
+	/// assert_eq!(Bits::count_ones(&192u8), 2);
+	/// assert_eq!(Bits::count_ones(&224u8), 3);
+	/// assert_eq!(Bits::count_ones(&240u8), 4);
+	/// assert_eq!(Bits::count_ones(&248u8), 5);
+	/// assert_eq!(Bits::count_ones(&252u8), 6);
+	/// assert_eq!(Bits::count_ones(&254u8), 7);
+	/// assert_eq!(Bits::count_ones(&255u8), 8);
+	/// ```
+	///
+	/// [`u64::count_ones`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.count_ones
+	#[inline(always)]
+	fn count_ones(&self) -> usize {
+		u64::count_ones((*self).into()) as usize
+	}
+
+	/// Counts how many bits in `self` are set to `0`.
+	///
+	/// This inverts `self`, so all `0` bits are `1` and all `1` bits are `0`,
+	/// then zero-extends `self` to `u64` and uses the [`u64::count_ones`]
+	/// inherent method.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of bits in `self` set to `0`. This is a `usize` instead of a
+	/// `u32` in order to ease arithmetic throughout the crate.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::bits::Bits;
+	/// assert_eq!(Bits::count_zeros(&0u8), 8);
+	/// assert_eq!(Bits::count_zeros(&1u8), 7);
+	/// assert_eq!(Bits::count_zeros(&3u8), 6);
+	/// assert_eq!(Bits::count_zeros(&7u8), 5);
+	/// assert_eq!(Bits::count_zeros(&15u8), 4);
+	/// assert_eq!(Bits::count_zeros(&31u8), 3);
+	/// assert_eq!(Bits::count_zeros(&63u8), 2);
+	/// assert_eq!(Bits::count_zeros(&127u8), 1);
+	/// assert_eq!(Bits::count_zeros(&255u8), 0);
+	/// ```
+	///
+	/// [`u64::count_ones`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.count_ones
+	#[inline(always)]
+	fn count_zeros(&self) -> usize {
+		//  invert (0 become 1, 1 become 0), zero-extend, count ones
+		u64::count_ones((!*self).into()) as usize
+	}
+}
+
+/** Newtype indicating a semantic index into an element.
+
+This type is consumed by [`Cursor`] implementors, which use it to produce a
+concrete bit position inside an element.
+
+`BitIdx` is a semantic counter which has a defined, constant, and predictable
+ordering. Values of `BitIdx` refer strictly to abstract ordering, and not to the
+actual position in an element, so `BitIdx(0)` is the first bit in an element,
+but is not required to be the electrical `LSb`, `MSb`, or any other.
+
+[`Cursor`]: ../trait.Cursor.html
+**/
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct BitIdx(pub(crate) u8);
+
+impl BitIdx {
+	/// Checks if the index is valid for a type.
+	///
+	/// Indices are valid in the range `0 .. T::SIZE`.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The index to validate.
+	///
+	/// # Returns
+	///
+	/// Whether the index is valid for the storage type in question.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type used to determine index validity.
+	pub fn is_valid<T: Bits>(self) -> bool {
+		*self < T::SIZE
+	}
+
+	/// Checks if the index is valid as a tail index for a type.
+	///
+	/// Tail indices are vaild in the range `1 ..= T::SIZE`.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The index to validate as a tail.
+	///
+	/// # Returns
+	///
+	/// Whether the index is valid as a tail for the storage type in question.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage used to determine index tail validity.
+	pub fn is_valid_tail<T: Bits>(self) -> bool {
+		*self > 0 && *self <= T::SIZE
+	}
+
+	/// Increments a cursor to the next value, wrapping if needed.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The original cursor.
+	///
+	/// # Returns
+	///
+	/// - `Self`: An incremented cursor.
+	/// - `bool`: Marks whether the increment crossed an element boundary.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type for which the increment will be
+	///   calculated.
+	///
+	/// # Panics
+	///
+	/// This method panics if `self` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example increments inside an element.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(3).incr::<u8>(), (4.into(), false));
+	/// # }
+	/// ```
+	///
+	/// This example increments at the high edge, and wraps to the next element.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(7).incr::<u8>(), (0.into(), true));
+	/// # }
+	/// ```
+	pub fn incr<T: Bits>(self) -> (Self, bool) {
+		assert!(
+			self.is_valid::<T>(),
+			"Index out of range: {} overflows {}",
+			*self,
+			T::SIZE,
+		);
+		let next = (*self).wrapping_add(1) & T::MASK;
+		(next.into(), next == 0)
+	}
+
+	/// Decrements a cursor to the previous value, wrapping if needed.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The original cursor.
+	///
+	/// # Returns
+	///
+	/// - `Self`: A decremented cursor.
+	/// - `bool`: Marks whether the decrement crossed an element boundary.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type for which the decrement will be
+	///   calculated.
+	///
+	/// # Panics
+	///
+	/// This method panics if `self` is not less than `T::SIZE`, in order to
+	/// avoid index out of range errors.
+	///
+	/// # Examples
+	///
+	/// This example decrements inside an element.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(5).decr::<u8>(), (4.into(), false));
+	/// # }
+	/// ```
+	///
+	/// This example decrements at the low edge, and wraps to the previous
+	/// element.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(0).decr::<u8>(), (7.into(), true));
+	/// # }
+	pub fn decr<T: Bits>(self) -> (Self, bool) {
+		assert!(
+			self.is_valid::<T>(),
+			"Index out of range: {} overflows {}",
+			*self,
+			T::SIZE,
+		);
+		let (prev, wrap) = (*self).overflowing_sub(1);
+		((prev & T::MASK).into(), wrap)
+	}
+
+	/// Finds the destination bit a certain distance away from a starting bit.
+	///
+	/// This produces the number of elements to move, and then the bit index of
+	/// the destination bit in the destination element.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The bit index in an element of the starting position. This
+	///   must be in the domain `0 .. T::SIZE`.
+	/// - `by`: The number of bits by which to move. Negative values move
+	///   downwards in memory: towards `LSb`, then starting again at `MSb` of
+	///   the prior element in memory (decreasing address). Positive values move
+	///   upwards in memory: towards `MSb`, then starting again at `LSb` of the
+	///   subsequent element in memory (increasing address).
+	///
+	/// # Returns
+	///
+	/// - `isize`: The number of elements by which to change the caller’s
+	///   element cursor. This value can be passed directly into [`ptr::offset`]
+	/// - `BitIdx`: The bit index of the destination bit in the newly selected
+	///   element. This will always be in the domain `0 .. T::SIZE`. This
+	///   value can be passed directly into [`Cursor`] functions to compute the
+	///   correct place in the element.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type with which the offset will be calculated.
+	///
+	/// # Panics
+	///
+	/// This function panics if `from` is not less than `T::SIZE`, in order
+	/// to avoid index out of range errors.
+	///
+	/// # Safety
+	///
+	/// `by` must not be large enough to cause the returned `isize` value to,
+	/// when applied to [`ptr::offset`], produce a reference out of bounds of
+	/// the original allocation. This method has no means of checking this
+	/// requirement.
+	///
+	/// # Examples
+	///
+	/// This example calculates offsets within the same element.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(1).offset::<u32>(4isize), (0, 5.into()));
+	/// assert_eq!(BitIdx::from(6).offset::<u32>(-3isize), (0, 3.into()));
+	/// # }
+	/// ```
+	///
+	/// This example calculates offsets that cross into other elements. It uses
+	/// `u32`, so the bit index domain is `0 ..= 31`.
+	///
+	/// `7 - 18`, modulo 32, wraps down from 0 to 31 and continues decreasing.
+	/// `23 + 68`, modulo 32, wraps up from 31 to 0 and continues increasing.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::BitIdx;
+	/// assert_eq!(BitIdx::from(7).offset::<u32>(-18isize), (-1, 21.into()));
+	/// assert_eq!(BitIdx::from(23).offset::<u32>(68isize), (2, 27.into()));
+	/// # }
+	/// ```
+	///
+	/// [`Cursor`]: ../trait.Cursor.html
+	/// [`ptr::offset`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset
+	pub fn offset<T: Bits>(self, by: isize) -> (isize, Self) {
+		assert!(
+			*self < T::SIZE,
+			"Index out of range: {} overflows {}",
+			*self,
+			T::SIZE,
+		);
+		//  If the `isize` addition does not overflow, then the sum can be used
+		//  directly.
+		if let (far, false) = by.overflowing_add(*self as isize) {
+			//  If `far` is in the domain `0 .. T::SIZE`, then the offset did
+			//  not depart the element.
+			if far >= 0 && far < T::SIZE as isize {
+				(0, (far as u8).into())
+			}
+			//  If `far` is negative, then the offset leaves the initial element
+			//  going down. If `far` is not less than `T::SIZE`, then the
+			//  offset leaves the initial element going up.
+			else {
+				//  `Shr` on `isize` sign-extends
+				(
+					far >> T::BITS,
+					((far & (T::MASK as isize)) as u8).into(),
+				)
+			}
+		}
+		//  If the `isize` addition overflows, then the `by` offset is positive.
+		//  Add as `usize` and use that. This is guaranteed not to overflow,
+		//  because `isize -> usize` doubles the domain, but `self` is limited
+		//  to `0 .. T::SIZE`.
+		else {
+			let far = *self as usize + by as usize;
+			//  This addition will always result in a `usize` whose lowest
+			//  `T::BITS` bits are the bit index in the destination element,
+			//  and the rest of the high bits (shifted down) are the number of
+			//  elements by which to advance.
+			(
+				(far >> T::BITS) as isize,
+				((far & (T::MASK as usize)) as u8).into(),
+			)
+		}
+	}
+
+	/// Computes the size of a span from `self` for `len` bits.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	/// - `len`: The number of bits to include in the span.
+	///
+	/// # Returns
+	///
+	/// - `usize`: The number of elements `T` included in the span. This will
+	///   be in the domain `1 .. usize::max_value()`.
+	/// - `BitIdx`: The index of the first bit *after* the span. This will be in
+	///   the domain `1 ..= T::SIZE`.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The type of the elements for which this span is computed.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::{BitIdx, Bits};
+	///
+	/// let h: BitIdx = 0.into();
+	/// assert_eq!(BitIdx::from(0).span::<u8>(8), (1, 8.into()))
+	/// # }
+	/// ```
+	pub fn span<T: Bits>(self, len: usize) -> (usize, BitIdx) {
+		//  Number of bits in the head *element*. Domain 32 .. 0.
+		let bits_in_head = (T::SIZE - *self) as usize;
+		//  If there are n bits live between the head cursor (which marks the
+		//  address of the first live bit) and the back edge of the element,
+		//  then when len is <= n, the span covers one element.
+		//  When len == n, the tail will be T::SIZE, which is valid for a tail.
+		if len <= bits_in_head {
+			(1, (*self + len as u8).into())
+		}
+		//  If there are more bits in the span than n, then subtract n from len
+		//  and use the difference to count elements and bits.
+		else {
+			//  1 ..
+			let bits_after_head = len - bits_in_head;
+			//  Count the number of wholly filled elements
+			let whole_elts = bits_after_head >> T::BITS;
+			//  Count the number of bits in the *next* element. If this is zero,
+			//  become T::SIZE; if it is nonzero, add one more to elts. elts
+			//  must have one added to it by default to account for the head
+			//  element.
+			let tail_bits = bits_after_head as u8 & T::MASK;
+			if tail_bits == 0 {
+				(whole_elts + 1, T::SIZE.into())
+			}
+			else {
+				(whole_elts + 2, tail_bits.into())
+			}
+		}
+	}
+}
+
+/// Wraps a `u8` as a `BitIdx`.
+impl From<u8> for BitIdx {
+	fn from(src: u8) -> Self {
+		BitIdx(src)
+	}
+}
+
+/// Unwraps a `BitIdx` to a `u8`.
+impl Into<u8> for BitIdx {
+	fn into(self) -> u8 {
+		self.0
+	}
+}
+
+impl Display for BitIdx {
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		write!(f, "BitIdx({})", self.0)
+	}
+}
+
+impl Deref for BitIdx {
+	type Target = u8;
+	fn deref(&self) -> &Self::Target { &self.0 } }
+
+impl DerefMut for BitIdx {
+	fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
+}
+
+/** Newtype indicating a concrete index into an element.
+
+This type is produced by [`Cursor`] implementors, and denotes a concrete bit in
+an element rather than a semantic bit.
+
+`Cursor` implementors translate `BitIdx` values, which are semantic places, into
+`BitPos` values, which are concrete electrical positions.
+
+[`Cursor`]: ../trait.Cursor.html
+**/
+#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct BitPos(u8);
+
+impl BitPos {
+	/// Checks if the position is valid for a type.
+	///
+	/// # Parameters
+	///
+	/// - `self`: The position to validate.
+	///
+	/// # Returns
+	///
+	/// Whether the position is valid for the storage type in question.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type used to determine position validity.
+	pub fn is_valid<T: Bits>(self) -> bool {
+		*self < T::SIZE
+	}
+}
+
+/// Wraps a `u8` as a `BitPos`.
+impl From<u8> for BitPos {
+	fn from(src: u8) -> Self {
+		BitPos(src)
+	}
+}
+
+/// Unwraps a `BitPos` to a `u8`.
+impl Into<u8> for BitPos {
+	fn into(self) -> u8 {
+		self.0
+	}
+}
+
+impl Display for BitPos {
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		write!(f, "BitPos({})", self.0)
+	}
+}
+
+impl Deref for BitPos {
+	type Target = u8;
+	fn deref(&self) -> &Self::Target { &self.0 }
+}
+
+impl DerefMut for BitPos {
+	fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
+}
+
+impl Bits for u8  { const TYPENAME: &'static str = "u8";  }
+impl Bits for u16 { const TYPENAME: &'static str = "u16"; }
+impl Bits for u32 { const TYPENAME: &'static str = "u32"; }
+#[cfg(target_pointer_width = "64")]
+impl Bits for u64 { const TYPENAME: &'static str = "u64"; }
+
+/// Marker trait to seal `Bits` against downstream implementation.
+///
+/// This trait is public in the module, so that other modules in the crate can
+/// use it, but so long as it is not exported by the crate root and this module
+/// is private, this trait effectively forbids downstream implementation of the
+/// `Bits` trait.
+#[doc(hidden)]
+pub trait Sealed {}
+
+impl Sealed for u8 {}
+impl Sealed for u16 {}
+impl Sealed for u32 {}
+
+#[cfg(target_pointer_width = "64")]
+impl Sealed for u64 {}
+
+#[cfg(test)]
+mod tests {
+	use super::*;
+
+	#[test]
+	fn jump_far_up() {
+		//  isize::max_value() is 0x7f...ff, so the result bit will be one less
+		//  than the start bit.
+		for n in 1 .. 8 {
+			let (elt, bit) = BitIdx::from(n).offset::<u8>(isize::max_value());
+			assert_eq!(elt, (isize::max_value() >> u8::BITS) + 1);
+			assert_eq!(*bit, n - 1);
+		}
+		let (elt, bit) = BitIdx::from(0).offset::<u8>(isize::max_value());
+		assert_eq!(elt, isize::max_value() >> u8::BITS);
+		assert_eq!(*bit, 7);
+	}
+
+	#[test]
+	fn jump_far_down() {
+		//  isize::min_value() is 0x80...00, so the result bit will be equal to
+		//  the start bit
+		for n in 0 .. 8 {
+			let (elt, bit) = BitIdx::from(n).offset::<u8>(isize::min_value());
+			assert_eq!(elt, isize::min_value() >> u8::BITS);
+			assert_eq!(*bit, n);
+		}
+	}
+
+	#[test]
+	#[should_panic]
+	fn offset_out_of_bound() {
+		BitIdx::from(64).offset::<u64>(isize::max_value());
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/boxed.rs
@@ -0,0 +1,938 @@
+/*! `BitBox` structure
+
+This module holds the type for an owned but ungrowable bit sequence. `BitVec` is
+the more appropriate and useful type for most collections.
+!*/
+
+#![cfg(feature = "alloc")]
+
+use crate::{
+	bits::Bits,
+	cursor::{
+		BigEndian,
+		Cursor,
+	},
+	pointer::BitPtr,
+	slice::BitSlice,
+	vec::BitVec,
+};
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::{
+	borrow::{
+		Borrow,
+		BorrowMut,
+		ToOwned,
+	},
+	boxed::Box,
+	vec::Vec,
+};
+use core::{
+	clone::Clone,
+	cmp::{
+		Eq,
+		PartialEq,
+		PartialOrd,
+		Ord,
+		Ordering,
+	},
+	convert::{
+		AsMut,
+		AsRef,
+		From,
+		Into,
+	},
+	default::Default,
+	fmt::{
+		self,
+		Debug,
+		Display,
+		Formatter,
+	},
+	hash::{
+		Hash,
+		Hasher,
+	},
+	iter::{
+		DoubleEndedIterator,
+		ExactSizeIterator,
+		FusedIterator,
+		Iterator,
+		IntoIterator,
+	},
+	marker::PhantomData,
+	mem,
+	ops::{
+		Add,
+		AddAssign,
+		BitAnd,
+		BitAndAssign,
+		BitOr,
+		BitOrAssign,
+		BitXor,
+		BitXorAssign,
+		Deref,
+		DerefMut,
+		Drop,
+		Index,
+		IndexMut,
+		Range,
+		RangeFrom,
+		RangeFull,
+		RangeInclusive,
+		RangeTo,
+		RangeToInclusive,
+		Neg,
+		Not,
+		Shl,
+		ShlAssign,
+		Shr,
+		ShrAssign,
+	},
+};
+#[cfg(feature = "std")]
+use std::{
+	borrow::{
+		Borrow,
+		BorrowMut,
+		ToOwned,
+	},
+	boxed::Box,
+	vec::Vec,
+};
+
+/** A pointer type for owned bit sequences.
+
+This type is essentially a `&BitSlice` that owns its own memory. It can change
+the contents of its domain, but it cannot change its own domain like `BitVec`
+can. It is useful for fixed-size collections without lifetime tracking.
+
+# Type Parameters
+
+- `C: Cursor`: An implementor of the [`Cursor`] trait. This type is used to
+  convert semantic indices into concrete bit positions in elements, and store or
+  retrieve bit values from the storage type.
+- `T: Bits`: An implementor of the [`Bits`] trait: `u8`, `u16`, `u32`, or `u64`.
+  This is the actual type in memory that the box will use to store data.
+
+# Safety
+
+The `BitBox` handle has the same *size* as standard Rust `Box<[T]>` handles, but
+it is ***extremely binary incompatible*** with them. Attempting to treat
+`BitBox<_, T>` as `Box<[T]>` in any manner except through the provided APIs is
+***catastrophically*** unsafe and unsound.
+
+# Trait Implementations
+
+`BitBox<C, T>` implements all the traits that `BitSlice<C, T>` does, by
+deferring to the `BitSlice` implementation. It also implements conversion traits
+to and from `BitSlice`, and to/from `BitVec`.
+**/
+#[repr(C)]
+pub struct BitBox<C = BigEndian, T = u8>
+where C: Cursor, T: Bits {
+	_cursor: PhantomData<C>,
+	pointer: BitPtr<T>,
+}
+
+impl<C, T> BitBox<C, T>
+where C: Cursor, T: Bits {
+	/// Constructs an empty slice at a given location.
+	///
+	/// # Parameters
+	///
+	/// - `data`: The address of the empty `BitBox` to construct.
+	///
+	/// # Returns
+	///
+	/// An empty `BitBox` at the given location.
+	pub fn uninhabited(data: *const T) -> Self {
+		Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::uninhabited(data),
+		}
+	}
+
+	/// Copies a `BitSlice` into an owned `BitBox`.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The `&BitSlice` to make owned.
+	///
+	/// # Returns
+	///
+	/// An owned clone of the given bit slice.
+	pub fn new(src: &BitSlice<C, T>) -> Self {
+		let store: Box<[T]> = src.as_ref().to_owned().into_boxed_slice();
+		let data = store.as_ptr();
+		let (_, elts, head, tail) = src.bitptr().raw_parts();
+		let out = Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::new(data, elts, head, tail),
+		};
+		mem::forget(store);
+		out
+	}
+
+	/// Constructs a `BitBox` from a raw `BitPtr`.
+	///
+	/// After calling this function, the raw pointer is owned by the resulting
+	/// `BitBox`. The `BitBox` will deallocate the memory region it describes.
+	///
+	/// # Parameters
+	///
+	/// - `pointer`: A `BitPtr<T>` describing a region of owned memory. This
+	///   must have previously produced by `BitBox` constructors; it is unsound
+	///   to even pass in `BitPtr<T>` values taken from `BitVec<C, T>` handles.
+	///
+	/// # Returns
+	///
+	/// An owned `BitBox` over the given pointer.
+	///
+	/// # Safety
+	///
+	/// Because Rust does not specify the allocation scheme used, the only
+	/// valid pointer to pass into this function is one that had previously been
+	/// produced by `BitBox` constructors and extracted by [`BitBox::into_raw`].
+	///
+	/// This function is unsafe because improper use can lead to double-free
+	/// errors (constructing multiple `BitBox`es from the same `BitPtr`) or
+	/// allocator inconsistencies (arbitrary pointers).
+	///
+	/// [`BitBox::into_raw`]: #method.into_raw
+	pub unsafe fn from_raw(pointer: BitPtr<T>) -> Self {
+		Self {
+			_cursor: PhantomData,
+			pointer,
+		}
+	}
+
+	/// Consumes the `BitBox`, returning the wrapped `BitPtr` directly.
+	///
+	/// After calling this function, the caller is responsible for the memory
+	/// previously managed by the `BitBox`. In particular, the caller must
+	/// properly release the memory region to which the `BitPtr` refers.
+	/// The proper way to do so is to convert the `BitPtr` back into a `BitBox`
+	/// with the [`BitBox::from_raw`] function.
+	///
+	/// Note: this is an associated function, which means that you must call it
+	/// as `BitBox::into_raw(b)` instead of `b.into_raw()`. This is to match the
+	/// API of [`Box`]; there is no method conflict with [`BitSlice`].
+	///
+	/// [`BitBox::from_raw`]: #method.from_raw
+	/// [`BitSlice`]: ../struct.BitSlice.html
+	#[cfg_attr(not(feature = "std"), doc = "[`Box`]: https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html")]
+	#[cfg_attr(feature = "std", doc = "[`Box`]: https://doc.rust-lang.org/stable/std/boxed/struct.Box.html")]
+	//  Permit associated function rather than method
+	#[allow(clippy::wrong_self_convention)]
+	pub unsafe fn into_raw(b: BitBox<C, T>) -> BitPtr<T> {
+		let out = b.bitptr();
+		mem::forget(b);
+		out
+	}
+
+	/// Consumes and leaks the `BitBox`, returning a mutable reference,
+	/// `&'a mut BitSlice<C, T>`. Note that the memory region `[T]` must outlive
+	/// the chosen lifetime `'a`.
+	///
+	/// This function is mainly useful for bit regions that live for the
+	/// remainder of the program’s life. Dropping the returned reference will
+	/// cause a memory leak. If this is not acceptable, the reference should
+	/// first be wrapped with the [`Box::from_raw`] function, producing a
+	/// `BitBox`. This `BitBox` can then be dropped which will properly
+	/// deallocate the memory.
+	///
+	/// Note: this is an associated function, which means that you must call it
+	/// as `BitBox::leak(b)` instead of `b.leak()`. This is to match the API of
+	/// [`Box`]; there is no method conflict with [`BitSlice`].
+	///
+	/// # Parameters
+	///
+	/// - `b`: The `BitBox` to deconstruct.
+	///
+	/// # Returns
+	///
+	/// The raw pointer from inside the `BitBox`.
+	///
+	/// [`BitBox::from_raw`]: #method.from_raw
+	/// [`BitSlice`]: ../struct.BitSlice.html
+	#[cfg_attr(not(feature = "std"), doc = "[`Box`]: https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html")]
+	#[cfg_attr(feature = "std", doc = "[`Box`]: https://doc.rust-lang.org/stable/std/boxed/struct.Box.html")]
+	pub fn leak<'a>(b: BitBox<C, T>) -> &'a mut BitSlice<C, T> {
+		let out = b.bitptr();
+		mem::forget(b);
+		out.into()
+	}
+
+	/// Changes the cursor on a box handle, without changing the data it
+	/// governs.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// An equivalent handle to the same data, with a new cursor parameter.
+	pub fn change_cursor<D>(self) -> BitBox<D, T>
+	where D: Cursor {
+		let bp = self.bitptr();
+		mem::forget(self);
+		unsafe { BitBox::from_raw(bp) }
+	}
+
+	/// Accesses the `BitSlice<C, T>` to which the `BitBox` refers.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The slice of bits behind the box.
+	pub fn as_bitslice(&self) -> &BitSlice<C, T> {
+		self.pointer.into()
+	}
+
+	/// Accesses the `BitSlice<C, T>` to which the `BitBox` refers.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The slice of bits behind the box.
+	pub fn as_mut_bitslice(&mut self) -> &mut BitSlice<C, T> {
+		self.pointer.into()
+	}
+
+	/// Gives read access to the `BitPtr<T>` structure powering the box.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A copy of the interior `BitPtr<T>`.
+	pub(crate) fn bitptr(&self) -> BitPtr<T> {
+		self.pointer
+	}
+
+	/// Allows a function to access the `Box<[T]>` that the `BitBox` is using
+	/// under the hood.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `func`: A function which works with a borrowed `Box<[T]>` representing
+	///   the actual memory held by the `BitBox`.
+	///
+	/// # Type Parameters
+	///
+	/// - `F: FnOnce(&Box<[T]>) -> R`: A function which borrows a box.
+	/// - `R`: The return value of the function.
+	///
+	/// # Returns
+	///
+	/// The return value of the provided function.
+	fn do_with_box<F, R>(&self, func: F) -> R
+	where F: FnOnce(&Box<[T]>) -> R {
+		let (data, elts, _, _) = self.bitptr().raw_parts();
+		let b: Box<[T]> = unsafe {
+			Vec::from_raw_parts(data as *mut T, elts, elts)
+		}.into_boxed_slice();
+		let out = func(&b);
+		mem::forget(b);
+		out
+	}
+}
+
+impl<C, T> Borrow<BitSlice<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn borrow(&self) -> &BitSlice<C, T> {
+		&*self
+	}
+}
+
+impl<C, T> BorrowMut<BitSlice<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn borrow_mut(&mut self) -> &mut BitSlice<C, T> {
+		&mut *self
+	}
+}
+
+impl<C, T> Clone for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn clone(&self) -> Self {
+		let (e, h, t) = self.bitptr().region_data();
+		let new_box = self.do_with_box(Clone::clone);
+		let ptr = new_box.as_ptr();
+		mem::forget(new_box);
+		Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::new(ptr, e, h, t),
+		}
+	}
+}
+
+impl<C, T> Eq for BitBox<C, T>
+where C: Cursor, T: Bits {}
+
+impl<C, T> Ord for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn cmp(&self, rhs: &Self) -> Ordering {
+		(&**self).cmp(&**rhs)
+	}
+}
+
+impl<A, B, C, D> PartialEq<BitBox<C, D>> for BitBox<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn eq(&self, rhs: &BitBox<C, D>) -> bool {
+		(&**self).eq(&**rhs)
+	}
+}
+
+impl<A, B, C, D> PartialEq<BitSlice<C, D>> for BitBox<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn eq(&self, rhs: &BitSlice<C, D>) -> bool {
+		(&**self).eq(rhs)
+	}
+}
+
+impl<A, B, C, D> PartialEq<BitBox<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn eq(&self, rhs: &BitBox<C, D>) -> bool {
+		self.eq(&**rhs)
+	}
+}
+
+impl<A, B, C, D> PartialOrd<BitBox<C, D>> for BitBox<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn partial_cmp(&self, rhs: &BitBox<C, D>) -> Option<Ordering> {
+		(&**self).partial_cmp(&**rhs)
+	}
+}
+
+impl<A, B, C, D> PartialOrd<BitSlice<C, D>> for BitBox<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn partial_cmp(&self, rhs: &BitSlice<C, D>) -> Option<Ordering> {
+		(&**self).partial_cmp(rhs)
+	}
+}
+
+impl<A, B, C, D> PartialOrd<BitBox<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn partial_cmp(&self, rhs: &BitBox<C, D>) -> Option<Ordering> {
+		self.partial_cmp(&**rhs)
+	}
+}
+
+impl<C, T> AsMut<BitSlice<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn as_mut(&mut self) -> &mut BitSlice<C, T> {
+		self.as_mut_bitslice()
+	}
+}
+
+impl<C, T> AsMut<[T]> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn as_mut(&mut self) -> &mut [T] {
+		(&mut **self).as_mut()
+	}
+}
+
+impl<C, T> AsRef<BitSlice<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn as_ref(&self) -> &BitSlice<C, T> {
+		self.as_bitslice()
+	}
+}
+
+impl<C, T> AsRef<[T]> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn as_ref(&self) -> &[T] {
+		(&**self).as_ref()
+	}
+}
+
+impl<C, T> From<&BitSlice<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn from(src: &BitSlice<C, T>) -> Self {
+		let (_, elts, head, tail) = src.bitptr().raw_parts();
+		let b: Box<[T]> = src.as_ref().to_owned().into_boxed_slice();
+		let out = Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::new(b.as_ptr(), elts, head, tail),
+		};
+		mem::forget(b);
+		out
+	}
+}
+
+/// Builds a `BitBox` out of a borrowed slice of elements.
+///
+/// This copies the memory as-is from the source buffer into the new `BitBox`.
+/// The source buffer will be unchanged by this operation, so you don't need to
+/// worry about using the correct cursor type for the read.
+///
+/// This operation does a copy from the source buffer into a new allocation, as
+/// it can only borrow the source and not take ownership.
+impl<C, T> From<&[T]> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	/// Builds a `BitBox<C: Cursor, T: Bits>` from a borrowed `&[T]`.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The elements to use as the values for the new vector.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let src: &[u8] = &[5, 10];
+	/// let bv: BitBox = src.into();
+	/// assert!(bv[5]);
+	/// assert!(bv[7]);
+	/// assert!(bv[12]);
+	/// assert!(bv[14]);
+	/// ```
+	fn from(src: &[T]) -> Self {
+		assert!(src.len() < BitPtr::<T>::MAX_ELTS, "Box overflow");
+		<&BitSlice<C, T>>::from(src).into()
+	}
+}
+
+impl<C, T> From<BitVec<C, T>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn from(mut src: BitVec<C, T>) -> Self {
+		src.shrink_to_fit();
+		let pointer = src.bitptr();
+		mem::forget(src);
+		unsafe { Self::from_raw(pointer) }
+	}
+}
+
+/// Builds a `BitBox` out of an owned slice of elements.
+///
+/// This moves the memory as-is from the source buffer into the new `BitBox`.
+/// The source buffer will be unchanged by this operation, so you don't need to
+/// worry about using the correct cursor type.
+impl<C, T> From<Box<[T]>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	/// Consumes a `Box<[T: Bits]>` and creates a `BitBox<C: Cursor, T>` from
+	/// it.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The source box whose memory will be used.
+	///
+	/// # Returns
+	///
+	/// A new `BitBox` using the `src` `Box`’s memory.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let src: Box<[u8]> = Box::new([3, 6, 9, 12, 15]);
+	/// let bv: BitBox = src.into();
+	/// ```
+	fn from(src: Box<[T]>) -> Self {
+		assert!(src.len() < BitPtr::<T>::MAX_ELTS, "Box overflow");
+		let out = Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::new(src.as_ptr(), src.len(), 0, T::SIZE)
+		};
+		mem::forget(src);
+		out
+	}
+}
+
+impl<C, T> Into<Box<[T]>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn into(self) -> Box<[T]> {
+		let (ptr, len, _, _) = self.bitptr().raw_parts();
+		let out = unsafe { Vec::from_raw_parts(ptr as *mut T, len, len) }
+			.into_boxed_slice();
+		mem::forget(self);
+		out
+	}
+}
+
+impl<C, T> Default for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn default() -> Self {
+		Self {
+			_cursor: PhantomData,
+			pointer: BitPtr::default(),
+		}
+	}
+}
+
+impl<C, T> Debug for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		f.write_str("BitBox<")?;
+		f.write_str(C::TYPENAME)?;
+		f.write_str(", ")?;
+		f.write_str(T::TYPENAME)?;
+		f.write_str("> ")?;
+		Display::fmt(&**self, f)
+	}
+}
+
+impl<C, T> Display for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		Display::fmt(&**self, f)
+	}
+}
+
+impl<C, T> Hash for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn hash<H: Hasher>(&self, hasher: &mut H) {
+		(&**self).hash(hasher)
+	}
+}
+
+impl<C, T> IntoIterator for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Item = bool;
+	type IntoIter = IntoIter<C, T>;
+
+	fn into_iter(self) -> Self::IntoIter {
+		IntoIter {
+			iterator: self.bitptr(),
+			_original: self,
+		}
+	}
+}
+
+impl<'a, C, T> IntoIterator for &'a BitBox<C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = bool;
+	type IntoIter = <&'a BitSlice<C, T> as IntoIterator>::IntoIter;
+
+	fn into_iter(self) -> Self::IntoIter {
+		(&**self).into_iter()
+	}
+}
+
+impl<C, T> Add<Self> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn add(mut self, addend: Self) -> Self::Output {
+		self += addend;
+		self
+	}
+}
+
+impl<C, T> AddAssign for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn add_assign(&mut self, addend: Self) {
+		**self += &*addend
+	}
+}
+
+impl<C, T, I> BitAnd<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	type Output = Self;
+
+	fn bitand(mut self, rhs: I) -> Self::Output {
+		self &= rhs;
+		self
+	}
+}
+
+impl<C, T, I> BitAndAssign<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	fn bitand_assign(&mut self, rhs: I) {
+		**self &= rhs;
+	}
+}
+
+impl<C, T, I> BitOr<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	type Output = Self;
+
+	fn bitor(mut self, rhs: I) -> Self::Output {
+		self |= rhs;
+		self
+	}
+}
+
+impl<C, T, I> BitOrAssign<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	fn bitor_assign(&mut self, rhs: I) {
+		**self |= rhs;
+	}
+}
+
+impl<C, T, I> BitXor<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	type Output = Self;
+
+	fn bitxor(mut self, rhs: I) -> Self::Output {
+		self ^= rhs;
+		self
+	}
+}
+
+impl<C, T, I> BitXorAssign<I> for BitBox<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	fn bitxor_assign(&mut self, rhs: I) {
+		**self ^= rhs;
+	}
+}
+
+impl<C, T> Deref for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Target = BitSlice<C, T>;
+
+	fn deref(&self) -> &Self::Target {
+		self.pointer.into()
+	}
+}
+
+impl<C, T> DerefMut for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn deref_mut(&mut self) -> &mut Self::Target {
+		self.pointer.into()
+	}
+}
+
+impl<C, T> Drop for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn drop(&mut self) {
+		let ptr = self.as_mut_bitslice().as_mut_ptr();
+		let len = self.as_bitslice().len();
+		//  Run the `Box<[T]>` destructor.
+		drop(unsafe { Vec::from_raw_parts(ptr, len, len).into_boxed_slice() });
+	}
+}
+
+impl<C, T> Index<usize> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = bool;
+
+	fn index(&self, index: usize) -> &Self::Output {
+		&(**self)[index]
+	}
+}
+
+impl<C, T> Index<Range<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: Range<usize>) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<Range<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: Range<usize>) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Index<RangeFrom<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: RangeFrom<usize>) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<RangeFrom<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: RangeFrom<usize>) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Index<RangeFull> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: RangeFull) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<RangeFull> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: RangeFull) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Index<RangeInclusive<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: RangeInclusive<usize>) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<RangeInclusive<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: RangeInclusive<usize>) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Index<RangeTo<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: RangeTo<usize>) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<RangeTo<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: RangeTo<usize>) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Index<RangeToInclusive<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = BitSlice<C, T>;
+
+	fn index(&self, range: RangeToInclusive<usize>) -> &Self::Output {
+		&(**self)[range]
+	}
+}
+
+impl<C, T> IndexMut<RangeToInclusive<usize>> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, range: RangeToInclusive<usize>) -> &mut Self::Output {
+		&mut (**self)[range]
+	}
+}
+
+impl<C, T> Neg for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn neg(mut self) -> Self::Output {
+		let _ = -(&mut *self);
+		self
+	}
+}
+
+impl<C, T> Not for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn not(mut self) -> Self::Output {
+		let _ = !(&mut *self);
+		self
+	}
+}
+
+impl<C, T> Shl<usize> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn shl(mut self, shamt: usize) -> Self::Output {
+		self <<= shamt;
+		self
+	}
+}
+
+impl<C, T> ShlAssign<usize> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn shl_assign(&mut self, shamt: usize) {
+		**self <<= shamt;
+	}
+}
+
+impl<C, T> Shr<usize> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn shr(mut self, shamt: usize) -> Self::Output {
+		self >>= shamt;
+		self
+	}
+}
+
+impl<C, T> ShrAssign<usize> for BitBox<C, T>
+where C: Cursor, T: Bits {
+	fn shr_assign(&mut self, shamt: usize) {
+		**self >>= shamt;
+	}
+}
+
+#[repr(C)]
+pub struct IntoIter<C, T>
+where C: Cursor, T: Bits {
+	/// Owning pointer to the full slab
+	_original: BitBox<C, T>,
+	/// Slice descriptor for the region undergoing iteration.
+	iterator: BitPtr<T>,
+}
+
+impl<C, T> IntoIter<C, T>
+where C: Cursor, T: Bits {
+	fn iterator(&self) -> <&BitSlice<C, T> as IntoIterator>::IntoIter {
+		<&BitSlice<C, T>>::from(self.iterator).into_iter()
+	}
+}
+
+impl<C, T> DoubleEndedIterator for IntoIter<C, T>
+where C: Cursor, T: Bits {
+	fn next_back(&mut self) -> Option<Self::Item> {
+		let mut slice_iter = self.iterator();
+		let out = slice_iter.next_back();
+		self.iterator = slice_iter.bitptr();
+		out
+	}
+}
+
+impl<C, T> ExactSizeIterator for IntoIter<C, T>
+where C: Cursor, T: Bits {}
+
+impl<C, T> FusedIterator for IntoIter<C, T>
+where C: Cursor, T: Bits {}
+
+impl<C, T> Iterator for IntoIter<C, T>
+where C: Cursor, T: Bits {
+	type Item = bool;
+
+	fn next(&mut self) -> Option<Self::Item> {
+		let mut slice_iter = self.iterator();
+		let out = slice_iter.next();
+		self.iterator = slice_iter.bitptr();
+		out
+	}
+
+	fn size_hint(&self) -> (usize, Option<usize>) {
+		self.iterator().size_hint()
+	}
+
+	fn count(self) -> usize {
+		self.len()
+	}
+
+	fn nth(&mut self, n: usize) -> Option<Self::Item> {
+		let mut slice_iter = self.iterator();
+		let out = slice_iter.nth(n);
+		self.iterator = slice_iter.bitptr();
+		out
+	}
+
+	fn last(mut self) -> Option<Self::Item> {
+		self.next_back()
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/cursor.rs
@@ -0,0 +1,129 @@
+/*! Bit Cursors
+
+`bitvec` structures are parametric over any ordering of bits within an element.
+The `Cursor` trait maps a cursor position (indicated by the `BitIdx` type) to an
+electrical position (indicated by the `BitPos` type) within that element, and
+also defines the order of traversal over an element.
+
+The only requirement on implementors of `Cursor` is that the transform function
+from cursor (`BitIdx`) to position (`BitPos`) is *total* (every integer in the
+domain `0 .. T::SIZE` is used) and *unique* (each cursor maps to one and only
+one position, and each position is mapped by one and only one cursor).
+Contiguity is not required.
+
+`Cursor` is a stateless trait, and implementors should be zero-sized types.
+!*/
+
+use super::bits::{
+	BitIdx,
+	BitPos,
+	Bits,
+};
+
+/// Traverses an element from `MSbit` to `LSbit`.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub struct BigEndian;
+
+/// Traverses an element from `LSbit` to `MSbit`.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub struct LittleEndian;
+
+/** A cursor over an element.
+
+# Usage
+
+`bitvec` structures store and operate on semantic counts, not bit positions. The
+`Cursor::at` function takes a semantic cursor, `BitIdx`, and produces an
+electrical position, `BitPos`.
+**/
+pub trait Cursor {
+	/// Name of the cursor type, for use in text display.
+	const TYPENAME: &'static str;
+
+	/// Translate a semantic bit index into an electrical bit position.
+	///
+	/// # Parameters
+	///
+	/// - `cursor`: The semantic bit value.
+	///
+	/// # Returns
+	///
+	/// - A concrete position. This value can be used for shifting and masking
+	///   to extract a bit from an element. This must be in the domain
+	///   `0 .. T::SIZE`.
+	///
+	/// # Type Parameters
+	///
+	/// - `T: Bits`: The storage type for which the position will be calculated.
+	///
+	/// # Invariants
+	///
+	/// The function **must** be *total* for the domain `.. T::SIZE`. All values
+	/// in this domain are valid indices that the library will pass to it, and
+	/// which this function must satisfy.
+	///
+	/// The function **must** be *bijective* over the domain `.. T::SIZE`. All
+	/// input values in this domain must have one and only one correpsonding
+	/// output, which must also be in this domain.
+	///
+	/// The function *may* support input in the domain `T::SIZE ..`. The library
+	/// will not produce any values in this domain as input indices. The
+	/// function **must not** produce output in the domain `T::SIZE ..`. It must
+	/// choose between panicking, or producing an output in `.. T::SIZE`. The
+	/// reduction in domain from `T::SIZE ..` to `.. T::SIZE` removes the
+	/// requirement for inputs in `T::SIZE ..` to have unique outputs in
+	/// `.. T::SIZE`.
+	///
+	/// This function **must** be *pure*. Calls which have the same input must
+	/// produce the same output. This invariant is only required to be upheld
+	/// for the lifetime of all data structures which use an implementor. The
+	/// behavior of the function *may* be modified after all existing dependent
+	/// data structures are destroyed and before any new dependent data
+	/// structures are created.
+	///
+	/// # Non-Invariants
+	///
+	/// This function is *not* required to be stateless. It *may* refer to
+	/// immutable global state, subject to the purity requirement on lifetimes.
+	///
+	/// # Safety
+	///
+	/// This function requires that the output be in the domain `.. T::SIZE`.
+	/// Implementors must uphold this themselves. Outputs in the domain
+	/// `T::SIZE ..` will induce panics elsewhere in the library.
+	fn at<T: Bits>(cursor: BitIdx) -> BitPos;
+}
+
+impl Cursor for BigEndian {
+	const TYPENAME: &'static str = "BigEndian";
+
+	/// Maps a semantic count to a concrete position.
+	///
+	/// `BigEndian` order moves from `MSbit` first to `LSbit` last.
+	fn at<T: Bits>(cursor: BitIdx) -> BitPos {
+		assert!(
+			*cursor < T::SIZE,
+			"Index out of range: {} overflows {}",
+			*cursor,
+			T::SIZE,
+		);
+		(T::MASK - *cursor).into()
+	}
+}
+
+impl Cursor for LittleEndian {
+	const TYPENAME: &'static str = "LittleEndian";
+
+	/// Maps a semantic count to a concrete position.
+	///
+	/// `LittleEndian` order moves from `LSbit` first to `MSbit` last.
+	fn at<T: Bits>(cursor: BitIdx) -> BitPos {
+		assert!(
+			*cursor < T::SIZE,
+			"Index out of range: {} overflows {}",
+			*cursor,
+			T::SIZE,
+		);
+		(*cursor).into()
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/domain.rs
@@ -0,0 +1,367 @@
+/*! Data Model for Bit Sequence Domains
+
+The domains governed by `BitSlice` and owned-variant handles have different
+representative states depending on the span of governed elements and live bits.
+
+This module provides representations of the domain states for ease of use by
+handle operations.
+!*/
+
+use crate::{
+	bits::{
+		BitIdx,
+		Bits,
+	},
+	pointer::BitPtr,
+};
+
+/// Variant markers for the kinds of domains.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub enum BitDomainKind {
+	/// Zero elements
+	Empty,
+	/// Single element, partial on both edges
+	Minor,
+	/// Multiple elements, partial on both edges
+	Major,
+	/// Partial on head only
+	PartialHead,
+	/// Partial on tail only
+	PartialTail,
+	/// Fully spans elements
+	Spanning,
+}
+
+impl BitDomainKind {
+	/// Tests if the variant is `Empty`.
+	pub fn is_empty(self)        -> bool { self == BitDomainKind::Empty       }
+	/// Tests if the variant is `Minor`.
+	pub fn is_minor(self)        -> bool { self == BitDomainKind::Minor       }
+	/// Tests if the variant is `Major`.
+	pub fn is_major(self)        -> bool { self == BitDomainKind::Major       }
+	/// Tests if the variant is `PartialHead`.
+	pub fn is_partial_head(self) -> bool { self == BitDomainKind::PartialHead }
+	/// Tests if the variant is `PartialTail`.
+	pub fn is_partial_tail(self) -> bool { self == BitDomainKind::PartialTail }
+	/// Tests if the variant is `Spanning`.
+	pub fn is_spanning(self)     -> bool { self == BitDomainKind::Spanning    }
+}
+
+impl<T> From<BitPtr<T>> for BitDomainKind
+where T: Bits {
+	fn from(bitptr: BitPtr<T>) -> Self {
+		let (e, h, t) = bitptr.region_data();
+		let w = T::SIZE;
+
+		match (e, *h, *t) {
+			//  Empty
+			(0, _, _)             => BitDomainKind::Empty,
+			//  Reaches both edges, for any number of elements
+			(_, 0, tc) if tc == w => BitDomainKind::Spanning,
+			//  Reaches only the tail edge, for any number of elements
+			(_, _, tc) if tc == w => BitDomainKind::PartialHead,
+			//  Reaches only the head edge, for any number of elements
+			(_, 0, _ )            => BitDomainKind::PartialTail,
+			//  Reaches neither edge, for one element
+			(1, _, _)             => BitDomainKind::Minor,
+			//  Reaches neither edge, for multiple elements
+			(_, _, _ )            => BitDomainKind::Major,
+		}
+	}
+}
+
+/// Representations of the state of the bit domain in its containing elements.
+///
+/// # Lifetimes
+///
+/// - `'a`: Lifetime of the containing storage
+///
+/// # Type Parameters
+///
+/// - `T: Bits` The type of the elements the domain inhabits.
+#[derive(Clone, Debug)]
+pub enum BitDomain<'a, T>
+where T: 'a + Bits {
+	/// Empty domain.
+	Empty,
+	/// Single element domain which does not reach either edge.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live domain bit in the element
+	/// - `.1`: reference to the element contatining the domain
+	/// - `.2`: index of the first dead bit after the domain
+	///
+	/// # Invariants
+	///
+	/// - `.0` must satisfy `BitIdx::is_valid::<T>`
+	/// - `.1` must satisfy `BitIdx::is_valid_tail::<T>`
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain is contained entirely inside
+	/// one element, and does not reach to either edge.
+	Minor(BitIdx, &'a T, BitIdx),
+	/// Multpile element domain which does not reach the edge of its edge
+	/// elements.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live domain bit in the first element
+	/// - `.1`: reference to the partial head edge element
+	/// - `.2`: slice handle to the fully-live elements in the interior. This
+	///   may be empty.
+	/// - `.3`: reference to the partial tail edge element
+	/// - `.4`: index of the first dead bit after the domain
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain uses at least two elements, and
+	/// reaches neither the head edge of the head element nor the tail edge of
+	/// the tail element.
+	Major(BitIdx, &'a T, &'a [T], &'a T, BitIdx),
+	/// Domain with a partial head cursor and fully extended tail cursor.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live bit in the head element
+	/// - `.1`: reference to the partial head element
+	/// - `.2`: reference to the full elements of the domain. This may be empty.
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain’s head cursor is past `0`, and
+	/// its tail cursor is exactly `T::SIZE`.
+	PartialHead(BitIdx, &'a T, &'a [T]),
+	/// Domain with a fully extended head cursor and partial tail cursor.
+	///
+	/// # Members
+	///
+	/// - `.0`: reference to the full elements of the domain. This may be empty.
+	/// - `.1`: reference to the partial tail element
+	/// - `.2`: index of the first dead bit after the live bits in the tail
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain’s head cursor is exactly `0`,
+	/// and its tail cursor is less than `T::SIZE`.
+	PartialTail(&'a [T], &'a T, BitIdx),
+	/// Domain which fully spans its containing elements.
+	///
+	/// # Members
+	///
+	/// - `.0`: slice handle to the elements containing the domain
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the all elements in the domain are fully
+	/// populated.
+	Spanning(&'a [T]),
+}
+
+impl<'a, T> From<BitPtr<T>> for BitDomain<'a, T>
+where T: 'a + Bits {
+	fn from(bitptr: BitPtr<T>) -> Self {
+		use BitDomainKind as Bdk;
+		let (e, h, t) = bitptr.region_data();
+		let data = bitptr.as_slice();
+
+		match bitptr.domain_kind() {
+			Bdk::Empty => BitDomain::Empty,
+			Bdk::Minor => BitDomain::Minor(h, &data[0], t),
+			Bdk::Major => BitDomain::Major(
+				h, &data[0], &data[1 .. e - 1], &data[e - 1], t
+			),
+			Bdk::PartialHead => BitDomain::PartialHead(
+				h, &data[0], &data[1 ..]
+			),
+			Bdk::PartialTail => BitDomain::PartialTail(
+				&data[.. e - 1], &data[e - 1], t
+			),
+			Bdk::Spanning => BitDomain::Spanning(data),
+		}
+	}
+}
+
+/// Representations of the state of the bit domain in its containing elements.
+///
+/// # Lifetimes
+///
+/// - `'a`: Lifetime of the containing storage
+///
+/// # Type Parameters
+///
+/// - `T: Bits` The type of the elements the domain inhabits.
+#[derive(Debug)]
+pub enum BitDomainMut<'a, T>
+where T: 'a + Bits {
+	/// Empty domain.
+	Empty,
+	/// Single element domain which does not reach either edge.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live domain bit in the element
+	/// - `.1`: mutable reference to the element contatining the domain
+	/// - `.2`: index of the first dead bit after the domain
+	///
+	/// # Invariants
+	///
+	/// - `.0` must satisfy `BitIdx::is_valid::<T>`
+	/// - `.1` must satisfy `BitIdx::is_valid_tail::<T>`
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain is contained entirely inside
+	/// one element, and does not reach to either edge.
+	Minor(BitIdx, &'a mut T, BitIdx),
+	/// Multpile element domain which does not reach the edge of its edge
+	/// elements.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live domain bit in the first element
+	/// - `.1`: mutable reference to the partial head edge element
+	/// - `.2`: mutable slice handle to the fully-live elements in the interior.
+	///   This may be empty.
+	/// - `.3`: mutable reference to the partial tail edge element
+	/// - `.4`: index of the first dead bit after the domain
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain uses at least two elements, and
+	/// reaches neither the head edge of the head element nor the tail edge of
+	/// the tail element.
+	Major(BitIdx, &'a mut T, &'a mut [T], &'a mut T, BitIdx),
+	/// Domain with a partial head cursor and fully extended tail cursor.
+	///
+	/// # Members
+	///
+	/// - `.0`: index of the first live bit in the head element
+	/// - `.1`: mutable reference to the partial head element
+	/// - `.2`: mutable reference to the full elements of the domain. This may
+	///   be empty.
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain’s head cursor is past `0`, and
+	/// its tail cursor is exactly `T::SIZE`.
+	PartialHead(BitIdx, &'a mut T, &'a mut [T]),
+	/// Domain with a fully extended head cursor and partial tail cursor.
+	///
+	/// # Members
+	///
+	/// - `.0`: mutable reference to the full elements of the domain. This may
+	///   be empty.
+	/// - `.1`: mutable reference to the partial tail element
+	/// - `.2`: index of the first dead bit after the live bits in the tail
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the domain’s head cursor is exactly `0`,
+	/// and its tail cursor is less than `T::SIZE`.
+	PartialTail(&'a mut [T], &'a mut T, BitIdx),
+	/// Domain which fully spans its containing elements.
+	///
+	/// # Members
+	///
+	/// - `.0`: mutable slice handle to the elements containing the domain
+	///
+	/// # Behavior
+	///
+	/// This variant is produced when the all elements in the domain are fully
+	/// populated.
+	Spanning(&'a mut [T]),
+}
+
+impl<'a, T> From<BitPtr<T>> for BitDomainMut<'a, T>
+where T: 'a + Bits {
+	fn from(bitptr: BitPtr<T>) -> Self {
+		use BitDomainKind as Bdk;
+		let (h, t) = bitptr.cursors();
+		let data = bitptr.as_mut_slice();
+
+		match bitptr.domain_kind() {
+			Bdk::Empty => BitDomainMut::Empty,
+			Bdk::Minor => BitDomainMut::Minor(h, &mut data[0], t),
+			Bdk::Major => {
+				let (head, body) = data.split_first_mut()
+					.expect("Major cannot fail to split head");
+				let (tail, body) = body.split_last_mut()
+					.expect("Major cannot fail to split tail");
+				BitDomainMut::Major(h, head, body, tail, t)
+			},
+			Bdk::PartialHead => {
+				let (head, tail) = data.split_first_mut()
+					.expect("PartialHead cannot fail to split");
+				BitDomainMut::PartialHead(h, head, tail)
+			},
+			Bdk::PartialTail => {
+				let (tail, head) = data.split_last_mut()
+					.expect("PartialTail cannot fail to split");
+				BitDomainMut::PartialTail(head, tail, t)
+			},
+			Bdk::Spanning => BitDomainMut::Spanning(data),
+		}
+	}
+}
+
+#[cfg(all(test, feature = "testing"))]
+mod tests {
+	use super::*;
+
+	#[test]
+	fn minor() {
+		let data: u8 = 0u8;
+		let bp = BitPtr::new(&data, 1, 1, 6);
+
+		assert!(bp.domain_kind().is_minor());
+	}
+
+	#[test]
+	fn major() {
+		let data: &[u16] = &[0u16, !0u16];
+		let bp = BitPtr::new(&data[0], 2, 1, 12);
+
+		assert!(bp.domain_kind().is_major());
+	}
+
+	#[test]
+	fn partial_head() {
+		let data: u32 = 0u32;
+		let bp = BitPtr::new(&data, 1, 4, 32);
+
+		assert!(bp.domain_kind().is_partial_head());
+
+		let data: &[u32] = &[0u32, !0u32];
+		let bp = BitPtr::new(&data[0], 2, 4, 32);
+
+		assert!(bp.domain_kind().is_partial_head());
+	}
+
+	#[test]
+	fn partial_tail() {
+		let data: u64 = 0u64;
+		let bp = BitPtr::new(&data, 1, 0, 60);
+
+		assert!(bp.domain_kind().is_partial_tail());
+
+		let data: &[u64] = &[0u64, !0u64];
+		let bp = BitPtr::new(&data[0], 2, 0, 60);
+
+		assert!(bp.domain_kind().is_partial_tail());
+	}
+
+	#[test]
+	fn spanning() {
+		let data: u8 = 0u8;
+		let bp = BitPtr::new(&data, 1, 0, 8);
+
+		assert!(bp.domain_kind().is_spanning());
+
+		let data: &[u16] = &[0u16, !0u16];
+		let bp = BitPtr::new(&data[0], 2, 0, 16);
+
+		assert!(bp.domain_kind().is_spanning());
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/lib.rs
@@ -0,0 +1,82 @@
+/*! `bitvec` – `[bool]` in overdrive.
+
+This crate provides views into slices of bits that are truly `[u1]`. Each bit in
+the data segment is used, unlike `[bool]` which ignores seven bits out of every
+byte.
+
+`bitvec`’s data structures provide strong guarantees about, and fine-grained
+control of, the bit-level representation of a sequence of memory. The user is
+empowered to choose the fundamental type underlying the store – `u8`, `u16`,
+`u32`, or `u64` – and the order in which each primitive is traversed –
+big-endian, from the most significant bit to the least, or little-endian, from
+the least significant bit to the most.
+
+This level of control is not necessary for most use cases where users just want
+to put bits in a sequence, but it is critically important for users making
+packets that leave main memory and hit some external device like a peripheral
+controller or a network socket. In order to provide convencienc to users for
+whom the storage details do not matter, `bitvec` types default to using
+big-endian bit order on `u8`. This means that the bits you would write down on
+paper match up with the bits as they are stored in memory.
+
+For example, the bit sequence `[0, 1, 1, 0, 1, 0, 0, 1]` inserted into `bitvec`
+structures with no extra type specification will produce the `<BigEndian, u8>`
+variant, so the bits in memory are `0b01101001`. With little-endian bit order,
+the memory value would be `0b10010110` (reversed order!).
+
+In addition to providing compact, efficient, and powerful storage and
+manipulation of bits in memory, the `bitvec` structures are capable of acting as
+a queue, set, or stream of bits. They implement the bit-wise operators for
+Boolean arithmetic, arithmetic operators for 2’s-complement numeric arithmetic,
+read indexing, bit shifts, and access to the underlying storage fundamental
+elements as a slice.
+
+(Write indexing is impossible in Rust semantics.)
+!*/
+
+#![cfg_attr(not(feature = "std"), no_std)]
+#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
+
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+extern crate alloc;
+
+#[cfg(feature = "std")]
+extern crate core;
+
+#[cfg(feature = "serdes")]
+extern crate serde;
+
+#[cfg(all(test, feature = "serdes"))]
+extern crate serde_test;
+
+#[macro_use]
+mod macros;
+
+pub mod bits;
+pub mod cursor;
+mod domain;
+mod pointer;
+pub mod prelude;
+pub mod slice;
+
+#[cfg(feature = "alloc")]
+pub mod boxed;
+
+#[cfg(feature = "alloc")]
+pub mod vec;
+
+#[cfg(all(feature = "serdes"))]
+mod serdes;
+
+/// Expose crate internals for use in doctests and external tests.
+#[cfg(feature = "testing")]
+pub mod testing {
+	pub use crate::{
+		bits::*,
+		domain::*,
+		macros::*,
+		pointer::*,
+		slice::*,
+		vec::*,
+	};
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/macros.rs
@@ -0,0 +1,211 @@
+/*! Utility macros for constructing data structures and implementing bulk types.
+
+The only public macro is `bitvec`; this module also provides convenience macros
+for code generation.
+!*/
+
+/** Construct a `BitVec` out of a literal array in source code, like `vec!`.
+
+`bitvec!` can be invoked in a number of ways. It takes the name of a `Cursor`
+implementation, the name of a `Bits`-implementing fundamental, and zero or more
+fundamentals (integer, floating-point, or boolean) which are used to build the
+bits. Each fundamental literal corresponds to one bit, and is considered to
+represent `1` if it is any other value than exactly zero.
+
+`bitvec!` can be invoked with no specifiers, a `Cursor` specifier, or a `Cursor`
+and a `Bits` specifier. It cannot be invoked with a `Bits` specifier but no
+`Cursor` specifier, due to overlap in how those tokens are matched by the macro
+system.
+
+Like `vec!`, `bitvec!` supports bit lists `[0, 1, …]` and repetition markers
+`[1; n]`.
+
+# All Syntaxes
+
+```rust
+use bitvec::prelude::*;
+
+bitvec![BigEndian, u8; 0, 1];
+bitvec![LittleEndian, u8; 0, 1,];
+bitvec![BigEndian; 0, 1];
+bitvec![LittleEndian; 0, 1,];
+bitvec![0, 1];
+bitvec![0, 1,];
+bitvec![BigEndian, u8; 1; 5];
+bitvec![LittleEndian; 0; 5];
+bitvec![1; 5];
+```
+**/
+#[cfg(feature = "alloc")]
+#[macro_export]
+macro_rules! bitvec {
+	//  bitvec![ endian , type ; 0 , 1 , … ]
+	( $endian:path , $bits:ty ; $( $element:expr ),* ) => {
+		bitvec![ __bv_impl__ $endian , $bits ; $( $element ),* ]
+	};
+	//  bitvec![ endian , type ; 0 , 1 , … , ]
+	( $endian:path , $bits:ty ; $( $element:expr , )* ) => {
+		bitvec![ __bv_impl__ $endian , $bits ; $( $element ),* ]
+	};
+
+	//  bitvec![ endian ; 0 , 1 , … ]
+	( $endian:path ; $( $element:expr ),* ) => {
+		bitvec![ __bv_impl__ $endian , u8 ; $( $element ),* ]
+	};
+	//  bitvec![ endian ; 0 , 1 , … , ]
+	( $endian:path ; $( $element:expr , )* ) => {
+		bitvec![ __bv_impl__ $endian , u8 ; $( $element ),* ]
+	};
+
+	//  bitvec![ 0 , 1 , … ]
+	( $( $element:expr ),* ) => {
+		bitvec![ __bv_impl__ $crate::prelude::BigEndian , u8 ; $( $element ),* ]
+	};
+	//  bitvec![ 0 , 1 , … , ]
+	( $( $element:expr , )* ) => {
+		bitvec![ __bv_impl__ $crate::prelude::BigEndian , u8 ; $( $element ),* ]
+	};
+
+	//  bitvec![ endian , type ; bit ; rep ]
+	( $endian:path , $bits:ty ; $element:expr ; $rep:expr ) => {
+		bitvec![ __bv_impl__ $endian , $bits ; $element; $rep ]
+	};
+	//  bitvec![ endian ; bit ; rep ]
+	( $endian:path ; $element:expr ; $rep:expr ) => {
+		bitvec![ __bv_impl__ $endian , u8 ; $element ; $rep ]
+	};
+	//  bitvec![ bit ; rep ]
+	( $element:expr ; $rep:expr ) => {
+		bitvec![ __bv_impl__ $crate::prelude::BigEndian , u8 ; $element ; $rep ]
+	};
+
+	//  Build an array of `bool` (one bit per byte) and then build a `BitVec`
+	//  from that (one bit per bit). I have yet to think of a way to make the
+	//  source array be binary-compatible with a `BitSlice` data representation,
+	//  so the static source is 8x larger than it needs to be.
+	//
+	//  I’m sure there is a way, but I don’t think I need to spend the effort
+	//  yet. Maybe a proc-macro.
+
+	( __bv_impl__ $endian:path , $bits:ty ; $( $element:expr ),* ) => {{
+		let init: &[bool] = &[ $( $element != 0 ),* ];
+		$crate :: vec :: BitVec :: < $endian , $bits > :: from ( init )
+	}};
+
+	( __bv_impl__ $endian:path , $bits:ty ; $element:expr ; $rep:expr ) => {{
+		core :: iter :: repeat ( $element != 0 )
+			.take ( $rep )
+			.collect :: < $crate :: vec :: BitVec < $endian , $bits > > ( )
+	}};
+}
+
+#[doc(hidden)]
+macro_rules! __bitslice_shift {
+	( $( $t:ty ),+ ) => { $(
+		#[doc(hidden)]
+		impl < C , T > core :: ops :: ShlAssign< $t >
+		for $crate :: prelude :: BitSlice<C, T>
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			fn shl_assign(&mut self, shamt: $t ) {
+				core :: ops :: ShlAssign::<usize>::shl_assign(self, shamt as usize);
+			}
+		}
+
+		#[doc(hidden)]
+		impl < C , T > core :: ops :: ShrAssign< $t >
+		for $crate :: prelude :: BitSlice<C, T>
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			fn shr_assign(&mut self, shamt: $t ) {
+				core :: ops :: ShrAssign::<usize>::shr_assign(self, shamt as usize);
+			}
+		}
+	)+ };
+}
+
+#[cfg(feature = "alloc")]
+#[doc(hidden)]
+macro_rules! __bitvec_shift {
+	( $( $t:ty ),+ ) => { $(
+		#[doc(hidden)]
+		impl < C , T > core :: ops :: Shl< $t >
+		for $crate :: vec :: BitVec < C , T >
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			type Output = <Self as core :: ops :: Shl<usize>>::Output;
+
+			fn shl(self, shamt: $t ) -> Self :: Output {
+				core :: ops :: Shl::<usize>::shl(self, shamt as usize)
+			}
+		}
+
+		#[doc(hidden)]
+		impl < C , T > core :: ops :: ShlAssign< $t >
+		for $crate :: vec :: BitVec < C , T >
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			fn shl_assign(&mut self, shamt: $t ) {
+				core :: ops :: ShlAssign::<usize>::shl_assign(self, shamt as usize)
+			}
+		}
+
+		#[doc(hidden)]
+		impl < C , T > core :: ops :: Shr< $t >
+		for $crate :: vec :: BitVec < C , T >
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			type Output = <Self as core :: ops :: Shr<usize>>::Output;
+
+			fn shr(self, shamt: $t ) -> Self :: Output {
+				core :: ops :: Shr::<usize>::shr(self, shamt as usize)
+			}
+		}
+
+		#[doc(hidden)]
+		impl < C , T> core :: ops :: ShrAssign< $t >
+		for $crate :: vec :: BitVec < C , T >
+		where C : $crate :: cursor :: Cursor , T : $crate :: bits :: Bits
+		{
+			fn shr_assign(&mut self, shamt: $t ) {
+				core :: ops :: ShrAssign::<usize>::shr_assign(self, shamt as usize)
+			}
+		}
+	)+ };
+}
+
+#[cfg(all(test, feature = "alloc"))]
+mod tests {
+	#[allow(unused_imports)]
+	use crate::cursor::{
+		BigEndian,
+		LittleEndian,
+	};
+
+	#[test]
+	fn compile_macros() {
+		bitvec![0, 1];
+		bitvec![BigEndian; 0, 1];
+		bitvec![LittleEndian; 0, 1];
+		bitvec![BigEndian, u8; 0, 1];
+		bitvec![LittleEndian, u8; 0, 1];
+		bitvec![BigEndian, u16; 0, 1];
+		bitvec![LittleEndian, u16; 0, 1];
+		bitvec![BigEndian, u32; 0, 1];
+		bitvec![LittleEndian, u32; 0, 1];
+		bitvec![BigEndian, u64; 0, 1];
+		bitvec![LittleEndian, u64; 0, 1];
+
+		bitvec![1; 70];
+		bitvec![BigEndian; 0; 70];
+		bitvec![LittleEndian; 1; 70];
+		bitvec![BigEndian, u8; 0; 70];
+		bitvec![LittleEndian, u8; 1; 70];
+		bitvec![BigEndian, u16; 0; 70];
+		bitvec![LittleEndian, u16; 1; 70];
+		bitvec![BigEndian, u32; 0; 70];
+		bitvec![LittleEndian, u32; 1; 70];
+		bitvec![BigEndian, u64; 0; 70];
+		bitvec![LittleEndian, u64; 1; 70];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/pointer.rs
@@ -0,0 +1,1179 @@
+/*! Raw Pointer Representation
+
+This module defines the binary representation of the handle to a `BitSlice`
+region. This structure is crate-internal, and defines the methods required to
+store a `BitSlice` pointer in memory and retrieve values from it suitable for
+work.
+!*/
+
+use crate::{
+	bits::{
+		BitIdx,
+		Bits,
+	},
+	cursor::Cursor,
+	domain::*,
+	slice::BitSlice,
+};
+use core::{
+	convert::{
+		AsMut,
+		AsRef,
+		From,
+	},
+	default::Default,
+	fmt::{
+		self,
+		Debug,
+		Formatter,
+	},
+	marker::PhantomData,
+	mem,
+	ptr::NonNull,
+	slice,
+};
+
+
+/// Width in bits of a pointer on the target machine.
+const PTR_BITS: usize = mem::size_of::<*const u8>() * 8;
+
+/// Width in bits of a processor word on the target machine.
+const USZ_BITS: usize = mem::size_of::<usize>() * 8;
+
+/** In-memory representation of `&BitSlice` handles.
+
+# Layout
+
+This structure is a more complex version of the `*const T`/`usize` tuple that
+Rust uses to represent slices throughout the language. It breaks the pointer and
+counter fundamentals into sub-field components. Rust does not have bitfield
+syntax, so the below description of the element layout is in C++.
+
+```cpp
+template<typename T>
+struct BitPtr<T> {
+  size_t ptr_head : __builtin_ctzll(alignof(T));
+  size_t ptr_data : sizeof(T*) * 8
+                  - __builtin_ctzll(alignof(T));
+
+  size_t len_head : 3;
+  size_t len_tail : 3
+                  + __builtin_ctzll(alignof(T));
+  size_t len_elts : sizeof(size_t) * 8
+                  - 6
+                  - __builtin_ctzll(alignof(T));
+};
+```
+
+This means that the `BitPtr<T>` structure has four *logical* fields, stored in
+five segments across the two *structural* fields of the type. The widths and
+placements of each segment are functions of the size of `*const T` and `usize`,
+and the alignment of `T`.
+
+# Fields
+
+This section describes the purpose, meaning, and layout of the four logical
+fields.
+
+## Data Pointer
+
+Aligned pointers to `T` always have low bits available for use to refine the
+address of a `T` to the address of a `u8`. It is stored in the high bits of the
+`ptr` field, running from MSb down to (inclusive)
+`core::mem::align_of::<T>().trailing_zeros()`.
+
+## Element Counter
+
+The memory representation stores counters that run from
+`1 ... (Self::MAX_ELTS)`, where the bit pattern is `n - 1` when `n` is the true
+number of elements in the slice’s domain. It is stored in the high bits of the
+`len` field, running from `MSb` down to (inclusive)
+`core::mem::align_of::<T>().trailing_zeros() + 6`.
+
+## Head Bit Counter
+
+For any fundamental type `T`, `core::mem::align_of::<T>().trailing_zeros() + 3`
+bits are required to count the bit positions inside it.
+
+|Type |Alignment|Trailing Zeros|Count Bits|
+|:----|--------:|-------------:|---------:|
+|`u8` |        1|             0|         3|
+|`u16`|        2|             1|         4|
+|`u32`|        4|             2|         5|
+|`u64`|        8|             3|         6|
+
+The head bit counter is split such that its bottom three bits are stored in the
+low bits of the `len` field and the remaining high bits are stored in the low
+bits of `ptr`.
+
+The counter is a value in the range `0 .. (1 << Count)` that serves as a cursor
+into the zeroth storage element to find the first live bit.
+
+## Tail Bit Counter
+
+This counter is the same bit width as the head bit counter. It is stored
+contiguously in the middle section of the `len` field, running from (exclusive)
+`core::mem::align_of::<T>().trailing_zeros() + 6` down to (inclusive) `3`. The
+value in it is a cursor to the next bit *after* the last live bit of the slice.
+
+The tail bit counter and the element counter operate together; when the tail bit
+counter is `0`, then the element counter is also incremented to cover the next
+element *after* the last live element in the slice domain.
+
+# Edge Cases
+
+The following value sets are edge cases of valid `BitPtr` structures.
+
+## Empty Slice
+
+The empty slice is canonically represented by a wholly zeroed slot:
+
+- `data`: `core::ptr::null::<T>()`
+- `elts`: `0usize`
+- `head`: `0u8`
+- `tail`: `0u8`
+- `ptr`: `core::ptr::null::<u8>()`
+- `len`: `0usize`
+
+All `BitPtr` values whose `data` pointer is `null` represents the empty slice,
+regardless of other field contents, but the normalized form zeros all other
+fields also.
+
+## Allocated, Uninhabited, Slice
+
+An allocated, owned, region of memory that is uninhabited. This is functionally
+the empty slice, but it must retain its pointer information. All other fields in
+the slot are zeroed.
+
+- `data`: (any valid `*const T`)
+- `elts`: `0usize`
+- `head`: `0u8`
+- `tail`: `0u8`
+- `ptr`: (any valid `*const u8`)
+- `len`: `0usize`
+
+## Maximum Elements, Maximum Tail
+
+This, unfortunately, cannot be represented. The largest domain that can be
+represented has `elts` and `tail` of `!0`, which leaves the last bit in the
+element unavailable.
+
+# Type Parameters
+
+- `T: Bits` is the storage type over which the pointer governs.
+
+# Safety
+
+A `BitPtr` must never be constructed such that the element addressed by
+`self.pointer().offset(self.elements())` causes an addition overflow. This will
+be checked in `new()`.
+
+A `BitPtr` must never be constructed such that the tail bit is lower in memory
+than the head bit. This will be checked in `new()`.
+
+# Undefined Behavior
+
+Using values of this type directly as pointers or counters will result in
+undefined behavior. The pointer value will be invalid for the type, and both the
+pointer and length values will be invalid for the memory model and allocation
+regime.
+**/
+#[repr(C)]
+#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)]
+pub struct BitPtr<T>
+where T: Bits {
+	_ty: PhantomData<T>,
+	/// Pointer to the first storage element of the slice.
+	///
+	/// This will always be a pointer to one byte, regardless of the storage
+	/// type of the `BitSlice` or the type parameter of `Self`. It is a
+	/// combination of a correctly typed and aligned pointer to `T`, and the
+	/// index of a byte within that element.
+	///
+	/// It is not necessarily the address of the byte with the first live bit.
+	/// The location of the first live bit within the first element is governed
+	/// by the [`Cursor`] type of the `BitSlice` using this structure.
+	///
+	/// [`Cursor`]: ../trait.Cursor.html
+	ptr: NonNull<u8>,
+	/// Three-element bitfield structure, holding length and place information.
+	///
+	/// This stores the element count in its highest bits, the tail [`BitIdx`]
+	/// cursor in the middle segment, and the low three bits of the head
+	/// `BitIdx` in the lowest three bits.
+	///
+	/// [`BitIdx`]: ../struct.BitIdx.html
+	len: usize,
+}
+
+impl<T> BitPtr<T>
+where T: Bits {
+	/// The number of high bits in `self.ptr` that are actually the address of
+	/// the zeroth `T`.
+	pub const PTR_DATA_BITS: usize = PTR_BITS - Self::PTR_HEAD_BITS;
+	/// Marks the bits of `self.ptr` that are the `data` section.
+	pub const PTR_DATA_MASK: usize = !Self::PTR_HEAD_MASK;
+
+	/// The number of low bits in `self.ptr` that are the high bits of the head
+	/// `BitIdx` cursor.
+	pub const PTR_HEAD_BITS: usize = T::BITS as usize - Self::LEN_HEAD_BITS;
+	/// Marks the bits of `self.ptr` that are the `head` section.
+	pub const PTR_HEAD_MASK: usize = T::MASK as usize >> Self::LEN_HEAD_BITS;
+
+	/// The number of low bits in `self.len` that are the low bits of the head
+	/// `BitIdx` cursor.
+	///
+	/// This is always `3`, until Rust tries to target a machine whose bytes are
+	/// not eight bits wide.
+	pub const LEN_HEAD_BITS: usize = 0b0011;
+	/// Marks the bits of `self.len` that are the `head` section.
+	pub const LEN_HEAD_MASK: usize = 0b0111;
+
+	/// The number of middle bits in `self.len` that are the tail `BitIdx`
+	/// cursor.
+	pub const LEN_TAIL_BITS: usize = T::BITS as usize;
+	/// Marks the bits of `self.len` that are the `tail` section.
+	pub const LEN_TAIL_MASK: usize = (T::MASK as usize) << Self::LEN_HEAD_BITS;
+
+	/// The number of high bits in `self.len` that are used to count `T`
+	/// elements in the slice.
+	pub const LEN_DATA_BITS: usize = USZ_BITS - Self::LEN_INDX_BITS;
+	/// Marks the bits of `self.len` that are the `data` section.
+	pub const LEN_DATA_MASK: usize = !Self::LEN_INDX_MASK;
+
+	/// The number of bits occupied by the `tail` `BitIdx` and the low 3 bits of
+	/// `head`.
+	pub const LEN_INDX_BITS: usize = Self::LEN_TAIL_BITS + Self::LEN_HEAD_BITS;
+	/// Marks the bits of `self.len` that are either `tail` or `head`.
+	pub const LEN_INDX_MASK: usize = Self::LEN_TAIL_MASK | Self::LEN_HEAD_MASK;
+
+	/// The maximum number of elements that can be stored in a `BitPtr` domain.
+	pub const MAX_ELTS: usize = 1 << Self::LEN_DATA_BITS;
+
+	/// The maximum number of bits that can be stored in a `BitPtr` domain.
+	pub const MAX_BITS: usize = !0 >> Self::LEN_HEAD_BITS;
+
+	/// Produces an empty-slice representation.
+	///
+	/// This has no live bits, and has a dangling pointer. It is useful as a
+	/// default value (and is the function used by `Default`) to indicate
+	/// arbitrary null slices.
+	///
+	/// # Returns
+	///
+	/// An uninhabited, uninhabitable, empty slice.
+	///
+	/// # Safety
+	///
+	/// The `BitPtr` returned by this function must never be dereferenced.
+	pub fn empty() -> Self {
+		Self {
+			_ty: PhantomData,
+			ptr: NonNull::dangling(),
+			len: 0,
+		}
+	}
+
+	/// Produces an uninhabited slice from a bare pointer.
+	///
+	/// # Parameters
+	///
+	/// - `ptr`: A pointer to `T`.
+	///
+	/// # Returns
+	///
+	/// If `ptr` is null, then this returns the empty slice; otherwise, the
+	/// returned slice is uninhabited and points to the given address.
+	///
+	/// # Panics
+	///
+	/// This function panics if the given pointer is not well aligned to its
+	/// type.
+	///
+	/// # Safety
+	///
+	/// The provided pointer must be either null, or valid in the caller’s
+	/// memory model and allocation regime.
+	pub fn uninhabited(ptr: *const T) -> Self {
+		//  Check that the pointer is properly aligned for the storage type.
+		//  Null pointers are always well aligned.
+		assert!(
+			(ptr as usize).trailing_zeros() as usize >= Self::PTR_HEAD_BITS,
+			"BitPtr domain pointers must be well aligned",
+		);
+		Self {
+			_ty: PhantomData,
+			ptr: NonNull::new(ptr as *mut u8).unwrap_or_else(NonNull::dangling),
+			len: 0,
+		}
+	}
+
+	/// Creates a new `BitPtr` from its components.
+	///
+	/// # Parameters
+	///
+	/// - `data`: A well-aligned pointer to a storage element. If this is null,
+	///   then the empty-slice representation is returned, regardless of other
+	///   parameter values.
+	/// - `elts`: A number of storage elements in the domain of the new
+	///   `BitPtr`. This number must be in `0 .. Self::MAX_ELTS`.
+	/// - `head`: The bit index of the first live bit in the domain. This must
+	///   be in the domain `0 .. T::SIZE`.
+	/// - `tail`: The bit index of the first dead bit after the domain. This
+	///   must be:
+	///   - equal to `head` when `elts` is `1`, to create an empty slice.
+	///   - in `head + 1 ..= T::SIZE` when `elts` is `1` to create a
+	///     single-element slice.
+	///   - in `1 ..= T::SIZE` when `elts` is greater than `1`.
+	///   - in `1 .. T::SIZE` when `elts` is `Self::MAX_ELTS - 1`.
+	///
+	/// # Returns
+	///
+	/// If `data` is null, then the empty slice is returned.
+	///
+	/// If either of the following conditions are true, then the uninhabited
+	/// slice is returned:
+	///
+	/// - `elts` is `0`,
+	/// - `elts` is `1` **and** `head` is equal to `tail`.
+	///
+	/// Otherwise, a `BitPtr` structure representing the given domain is
+	/// returned.
+	///
+	/// # Type Parameters
+	///
+	/// - `Head: Into<BitIdx>`: A type which can be used as a `BitIdx`.
+	/// - `Tail: Into<BitIdx>`: A type which can be used as a `BitIdx`.
+	///
+	/// # Panics
+	///
+	/// This function happily panics at the slightest whiff of impropriety.
+	///
+	/// - If the `data` pointer is not aligned to at least the type `T`,
+	/// - If the `elts` counter is not within the countable elements domain,
+	///   `0 .. Self::MAX_ELTS`,
+	/// - If the `data` pointer is so high in the address space that addressing
+	///   the last element would cause the pointer to wrap,
+	/// - If `head` or `tail` are too large for indexing bits within `T`,
+	/// - If `tail` is not correctly placed relative to `head`.
+	///
+	/// # Safety
+	///
+	/// The `data` pointer and `elts` counter must describe a correctly aligned,
+	/// validly allocated, region of memory. The caller is responsible for
+	/// ensuring that the slice of memory that the new `BitPtr` will govern is
+	/// all governable.
+	pub fn new<Head: Into<BitIdx>, Tail: Into<BitIdx>>(
+		data: *const T,
+		elts: usize,
+		head: Head,
+		tail: Tail,
+	) -> Self {
+		//  Everything gets weird if this axiom is disproven.
+		assert!(
+			elts <= isize::max_value() as usize,
+			"elts cannot exceed isize::max_value()",
+		);
+
+		let (head, tail) = (head.into(), tail.into());
+		//  null pointers, and pointers to empty regions, are run through the
+		//  uninhabited constructor instead
+		if data.is_null() || elts == 0 || (elts == 1 && head == tail) {
+			return Self::uninhabited(data);
+		}
+
+		//  Check that the pointer is properly aligned for the storage type.
+		assert!(
+			(data as usize).trailing_zeros() as usize >= Self::PTR_HEAD_BITS,
+			"BitPtr domain pointers must be well aligned",
+		);
+
+		//  Check that the slice domain is below the ceiling.
+		assert!(
+			elts < Self::MAX_ELTS,
+			"BitPtr domain regions must have at most {} elements",
+			Self::MAX_ELTS - 1,
+		);
+
+		//  Check that the pointer is not so high in the address space that the
+		//  slice domain wraps.
+		if data.wrapping_add(elts) < data {
+			panic!("BitPtr slices MUST NOT wrap around the address space");
+		}
+
+		//  Check that the head cursor index is within the storage element.
+		assert!(
+			head.is_valid::<T>(),
+			"BitPtr head cursors must be in the domain 0 .. {}",
+			T::SIZE,
+		);
+
+		//  Check that the tail cursor index is in the appropriate domain.
+		assert!(
+			tail.is_valid_tail::<T>(),
+			"BitPtr tail cursors must be in the domain 1 ..= {}",
+			T::SIZE,
+		);
+
+		//  For single-element slices, check that the tail cursor is after the
+		//  head cursor (single-element, head == tail, is checked above).
+		if elts == 1 {
+			assert!(
+				tail > head,
+				"BitPtr domains with one element must have the tail cursor \
+				beyond the head cursor",
+			);
+		}
+		else if elts == Self::MAX_ELTS - 1 {
+			assert!(
+				tail.is_valid::<T>(),
+				"BitPtr domains with maximum elements must have the tail \
+				cursor in 1 .. {}",
+				T::SIZE,
+			);
+		}
+
+		//  All invariants satisfied; build the fields
+		let ptr_data = data as usize & Self::PTR_DATA_MASK;
+		let ptr_head = *head as usize >> Self::LEN_HEAD_BITS;
+
+		let len_elts = elts << Self::LEN_INDX_BITS;
+		//  Store tail. Note that this wraps T::SIZE to 0. This must be
+		//  reconstructed during retrieval.
+		let len_tail
+			= ((*tail as usize) << Self::LEN_HEAD_BITS)
+			& Self::LEN_TAIL_MASK;
+		let len_head = *head as usize & Self::LEN_HEAD_MASK;
+
+		Self {
+			_ty: PhantomData,
+			ptr: unsafe {
+				NonNull::new_unchecked((ptr_data | ptr_head) as *mut u8)
+			},
+			len: len_elts | len_tail | len_head,
+		}
+	}
+
+	/// Extracts the pointer to the first storage element.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The `*const T` address of the first storage element in the slice domain.
+	///
+	/// # Safety
+	///
+	/// This pointer must be valid in the user’s memory model and allocation
+	/// regime.
+	pub fn pointer(&self) -> *const T {
+		(self.ptr.as_ptr() as usize & Self::PTR_DATA_MASK) as *const T
+	}
+
+	/// Produces the count of all elements in the slice domain.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of `T` elements in the slice domain.
+	///
+	/// # Safety
+	///
+	/// This size must be valid in the user’s memory model and allocation
+	/// regime.
+	pub fn elements(&self) -> usize {
+		self.len >> Self::LEN_INDX_BITS
+	}
+
+	/// Extracts the element cursor of the head bit.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A `BitIdx` that is the index of the first live bit in the first element.
+	/// This will be in the domain `0 .. T::SIZE`.
+	pub fn head(&self) -> BitIdx {
+		((((self.ptr.as_ptr() as usize & Self::PTR_HEAD_MASK) << 3)
+		| (self.len & Self::LEN_HEAD_MASK)) as u8).into()
+	}
+
+	/// Extracts the element cursor of the first dead bit *after* the tail bit.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A `BitIdx` that is the index of the first dead bit after the last live
+	/// bit in the last element. This will be in the domain `1 ..= T::SIZE`.
+	pub fn tail(&self) -> BitIdx {
+		let bits = (self.len & Self::LEN_TAIL_MASK) >> Self::LEN_HEAD_BITS;
+		if bits == 0 { T::SIZE } else { bits as u8 }.into()
+	}
+
+	/// Decomposes the pointer into raw components.
+	///
+	/// The values returned from this can be immediately passed into `::new` in
+	/// order to rebuild the pointer.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `*const T`: A well aligned pointer to the first element of the slice.
+	/// - `usize`: The number of elements in the slice.
+	/// - `BitIdx`: The index of the first live bit in the first element.
+	/// - `BitIdx`: The index of the first dead bit in the last element.
+	pub fn raw_parts(&self) -> (*const T, usize, BitIdx, BitIdx) {
+		(self.pointer(), self.elements(), self.head(), self.tail())
+	}
+
+	/// Produces the bare structural components of the pointer handle.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `*const ()`: The pointer member. This is unlikely to be the address
+	///   of the region, and is meaningless to dereference.
+	/// - `usize`: The length member. This is *not* the length of the region and
+	///   is *not* valid to use for indexing.
+	pub(crate) unsafe fn bare_parts(&self) -> (*const (), usize) {
+		(self.ptr.as_ptr() as *const (), self.len)
+	}
+
+	/// Produces the element count, head index, and tail index, which describe
+	/// the region.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `usize`: The number of elements in the slice.
+	/// - `BitIdx`: The index of the first live bit in the first element.
+	/// - `BitIdx`: The index of the first dead bit in the last element.
+	pub fn region_data(&self) -> (usize, BitIdx, BitIdx) {
+		(self.elements(), self.head(), self.tail())
+	}
+
+	/// Produces the head and tail indices for the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `BitIdx`: The index of the first live bit in the first element.
+	/// - `BitIdx`: The index of the first dead bit in the last element.
+	pub fn cursors(&self) -> (BitIdx, BitIdx) {
+		(self.head(), self.tail())
+	}
+
+	/// Checks if the pointer represents the empty slice.
+	///
+	/// The empty slice has a dangling `data` pointer and zeroed `elts`, `head`,
+	/// and `tail` elements.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether the slice is empty or inhabited.
+	pub fn is_empty(&self) -> bool {
+		self.len >> Self::LEN_INDX_BITS == 0
+	}
+
+	/// Checks if the pointer represents the full slice.
+	///
+	/// The full slice is marked by `!0` values for `elts` and `tail`, when
+	/// `data` is not null. The full slice does not need `head` to be `0`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether the slice is fully extended or not.
+	pub fn is_full(&self) -> bool {
+		//  Self must be:
+		//  - not empty
+		//  - `!0` in `elts` and `tail`
+		!self.is_empty()
+		&& ((self.len | Self::LEN_HEAD_MASK) == !0)
+	}
+
+	///  Counts how many bits are in the domain of a `BitPtr` slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A count of the live bits in the slice.
+	pub fn bits(&self) -> usize {
+		if self.is_empty() {
+			return 0;
+		}
+		let (_, elts, head, tail) = self.raw_parts();
+		if elts == 1 {
+			return *tail as usize - *head as usize;
+		}
+		//  The number of bits in a domain is calculated by decrementing `elts`,
+		//  multiplying it by the number of bits per element, then subtracting
+		//  `head` (which is the number of dead bits in the front of the first
+		//  element), and adding `tail` (which is the number of live bits in the
+		//  front of the last element).
+		((elts - 1) << T::BITS)
+			.saturating_add(*tail as usize)
+			.saturating_sub(*head as usize)
+	}
+
+	/// Produces the head element, if and only if it is partially live.
+	///
+	/// If the head element is completely live, this returns `None`, because the
+	/// head element is returned in `body_elts()`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// `Some(&T)` if the slice has at least one element, and the first element
+	/// has at least one bit dead.
+	///
+	/// `None` if the slice is empty, or if the first element is completely
+	/// live.
+	pub fn head_elt(&self) -> Option<&T> {
+		if !self.is_empty() && *self.head() > 0 {
+			return Some(&self.as_ref()[0]);
+		}
+		None
+	}
+
+	/// Produces the slice of middle elements that are all fully live.
+	///
+	/// This may produce the empty slice, if the `BitPtr` slice domain has zero,
+	/// one, or two elements, and the outer elements are only partially live.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A slice of fully live storage elements.
+	pub fn body_elts(&self) -> &[T] {
+		let w = T::SIZE;
+		let (_, e, h, t) = self.raw_parts();
+		match (e, *h, *t) {
+			//  Empty slice
+			(0, _, _)           => &             [          ],
+			//  Single-element slice, with cursors at the far edges
+			(1, 0, t) if t == w => &self.as_ref()[0 .. e    ],
+			//  Single-element slice, with partial cursors
+			(1, _, _)           => &             [          ],
+			//  Multiple-element slice, with cursors at the far edges
+			(_, 0, t) if t == w => &self.as_ref()[0 .. e    ],
+			//  Multiple-element slice, with full head and partial tail
+			(_, 0, _)           => &self.as_ref()[0 .. e - 1],
+			//  Multiple-element slice, with partial tail and full head
+			(_, _, t) if t == w => &self.as_ref()[1 .. e    ],
+			//  Multiple-element slice, with partial cursors
+			(_, _, _)           => &self.as_ref()[1 .. e - 1],
+		}
+	}
+
+	/// Produces the tail element, if and only if it is partially live.
+	///
+	/// If the tail element is completely live, this returns `None`, because the
+	/// tail element is returned in `body_elts()`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// `Some(&T)` if the slice has at least one element, and the last element
+	/// has at least one bit dead.
+	///
+	/// `None` if the slice is empty, or if the last element is completely live.
+	pub fn tail_elt(&self) -> Option<&T> {
+		if !self.is_empty() && *self.tail() < T::SIZE {
+			return Some(&self.as_ref()[self.elements() - 1]);
+		}
+		None
+	}
+
+	/// Accesses the element slice behind the pointer as a Rust slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Standard Rust slice handle over the data governed by this pointer.
+	///
+	/// # Lifetimes
+	///
+	/// - `'a`: Lifetime for which the data behind the pointer is live.
+	pub fn as_slice<'a>(&self) -> &'a [T] {
+		unsafe { slice::from_raw_parts(self.pointer(), self.elements()) }
+	}
+
+	/// Accesses the element slice behind the pointer as a Rust mutable slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Standard Rust slice handle over the data governed by this pointer.
+	///
+	/// # Lifetimes
+	///
+	/// - `'a`: Lifetime for which the data behind the pointer is live.
+	pub fn as_mut_slice<'a>(&self) -> &'a mut [T] {
+		unsafe {
+			slice::from_raw_parts_mut(self.pointer() as *mut T, self.elements())
+		}
+	}
+
+	/// Gets the domain kind for the region the pointer describes.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An enum describing the live bits in the region the pointer covers.
+	pub fn domain_kind(&self) -> BitDomainKind {
+		(*self).into()
+	}
+
+	/// Gets the domain for the region the pointer describes.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An enum containing the logical components of the domain governed by
+	/// `self`.
+	pub fn domain(&self) -> BitDomain<T> {
+		(*self).into()
+	}
+
+	/// Gets the domain for the region the pointer describes.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An enum containing the logical components of the domain governed by
+	/// `self`.
+	pub fn domain_mut(&self) -> BitDomainMut<T> {
+		(*self).into()
+	}
+
+	/// Set the head index to a new value.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `head`: The new index to which the head will be set.
+	///
+	/// # Type Parameters
+	///
+	/// - `Head: Into<BitIdx>`: A type which can be used as a semantic bit
+	/// index.
+	pub fn set_head<Head: Into<BitIdx>>(&mut self, head: Head) {
+		if self.is_empty() {
+			return;
+		}
+		let head = head.into();
+		assert!(
+			head.is_valid::<T>(),
+			"Head indices must be in the domain 0 .. {}",
+			T::SIZE,
+		);
+		if self.elements() == 1 {
+			assert!(
+				head <= self.tail(),
+				"Single-element slices must have head below tail",
+			);
+		}
+		self.ptr = unsafe {
+			let ptr = self.ptr.as_ptr() as usize;
+			NonNull::new_unchecked(
+				((ptr & !Self::PTR_HEAD_MASK)
+				| ((*head as usize >> Self::LEN_HEAD_BITS) & Self::PTR_HEAD_MASK)
+				) as *mut u8
+			)
+		};
+		self.len &= !Self::LEN_HEAD_MASK;
+		self.len |= *head as usize & Self::LEN_HEAD_MASK;
+	}
+
+	/// Moves the `head` cursor upwards by one.
+	///
+	/// If `head` is at the back edge of the first element, then it will be set
+	/// to the front edge of the second element, and the pointer will be moved
+	/// upwards.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Safety
+	///
+	/// This method is unsafe when `self` is directly, solely, managing owned
+	/// memory. It mutates the pointer and element count, so if this pointer is
+	/// solely responsible for owned memory, its conception of the allocation
+	/// will differ from the allocator’s.
+	pub unsafe fn incr_head(&mut self) {
+		let (data, elts, head, tail) = self.raw_parts();
+		let (h, wrap) = head.incr::<T>();
+		if wrap {
+			*self = Self::new(data.offset(1), elts.saturating_sub(1), h, tail);
+		}
+		else {
+			*self = Self::new(data, elts, h, tail);
+		}
+	}
+
+	/// Moves the `head` cursor downwards by one.
+	///
+	/// If `head` is at the front edge of the first element, then it will be set
+	/// to the back edge of the zeroth element, and the pointer will be moved
+	/// downwards.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Safety
+	///
+	/// This function is unsafe when `self` is directly, solely, managing owned
+	/// memory. It mutates the pointer and element count, so if this pointer is
+	/// solely responsible for owned memory, its conception of the allocation
+	/// will differ from the allocator’s.
+	pub unsafe fn decr_head(&mut self) {
+		let (data, elts, head, tail) = self.raw_parts();
+		let (h, wrap) = head.decr::<T>();
+		if wrap {
+			*self = Self::new(data.offset(-1), elts.saturating_add(1), h, tail);
+		}
+		else {
+			*self = Self::new(data, elts, h, tail);
+		}
+	}
+
+	/// Set the tail index to a new value.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `tail`: The new index to which the tail will be set.
+	///
+	/// # Type Parameters
+	///
+	/// - `Tail: Into<BitIdx>`: A type which can be used as a semantic bit
+	/// index.
+	pub fn set_tail<Tail: Into<BitIdx>>(&mut self, tail: Tail) {
+		if self.is_empty() {
+			return;
+		}
+		let tail = tail.into();
+		assert!(
+			tail.is_valid_tail::<T>(),
+			"Tail indices must be in the domain 1 ..= {}",
+			T::SIZE,
+		);
+		if self.elements() == 1 {
+			assert!(
+				tail >= self.head(),
+				"Single-element slices must have tail above head",
+			);
+		}
+		self.len &= !Self::LEN_TAIL_MASK;
+		self.len |= *tail as usize
+	}
+
+	/// Moves the `tail` cursor upwards by one.
+	///
+	/// If `tail` is at the back edge of the last element, then it will be set
+	/// to the front edge of the next element beyond, and the element count will
+	/// be increased.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Safety
+	///
+	/// This function is unsafe when `self` is directly, solely, managing owned
+	/// memory. It mutates the element count, so if this pointer is solely
+	/// responsible for owned memory, its conception of the allocation will
+	/// differ from the allocator’s.
+	pub unsafe fn incr_tail(&mut self) {
+		let (data, elts, head, tail) = self.raw_parts();
+		let decr = BitIdx::from(*tail - 1);
+		let (mut new_tail, wrap) = decr.incr::<T>();
+		new_tail = BitIdx::from(*new_tail + 1);
+		*self = Self::new(data, elts + wrap as usize, head, new_tail);
+	}
+
+	/// Moves the `tail` cursor downwards by one.
+	///
+	/// If `tail` is at the front edge of the back element, then it will be set
+	/// to the back edge of the next element forward, and the element count will
+	/// be decreased.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Safety
+	///
+	/// This function is unsafe when `self` is directly, solely, managing owned
+	/// memory. It mutates the element count, so if this pointer is solely
+	/// responsible for owned memory, its conception of the allocation will
+	/// differ from the allocator’s.
+	pub unsafe fn decr_tail(&mut self) {
+		let (data, elts, head, tail) = self.raw_parts();
+		let decr = BitIdx::from(*tail - 1);
+		let (mut new_tail, wrap) = decr.decr::<T>();
+		new_tail = BitIdx::from(*new_tail + 1);
+		*self = Self::new(data, elts - wrap as usize, head, new_tail);
+	}
+}
+
+/// Gets write access to all elements in the underlying storage, including the
+/// partial head and tail elements.
+///
+/// # Safety
+///
+/// This is *unsafe* to use except from known mutable `BitSlice` structures.
+/// Mutability is not encoded in the `BitPtr` type system at this time, and thus
+/// is not enforced by the compiler yet.
+impl<T> AsMut<[T]> for BitPtr<T>
+where T: Bits {
+	fn as_mut(&mut self) -> &mut [T] {
+		self.as_mut_slice()
+	}
+}
+
+/// Gets read access to all elements in the underlying storage, including the
+/// partial head and tail elements.
+impl<T> AsRef<[T]> for BitPtr<T>
+where T: Bits {
+	fn as_ref(&self) -> &[T] {
+		self.as_slice()
+	}
+}
+
+/// Constructs from an immutable `BitSlice` reference handle.
+impl<'a, C, T> From<&'a BitSlice<C, T>> for BitPtr<T>
+where C: Cursor, T: 'a + Bits {
+	fn from(src: &'a BitSlice<C, T>) -> Self {
+		let src = unsafe { &*(src as *const BitSlice<C, T> as *const [()]) };
+		let (ptr, len) = match (src.as_ptr(), src.len()) {
+			(_, 0) => (NonNull::dangling(), 0),
+			(p, _) if p.is_null() => unreachable!(
+				"Slices cannot have a length when they begin at address 0"
+			),
+			(p, l) => (unsafe { NonNull::new_unchecked(p as *mut u8) }, l),
+		};
+		Self { ptr, len, _ty: PhantomData }
+	}
+}
+
+/// Constructs from a mutable `BitSlice` reference handle.
+impl<'a, C, T> From<&'a mut BitSlice<C, T>> for BitPtr<T>
+where C: Cursor, T: 'a + Bits {
+	fn from(src: &'a mut BitSlice<C, T>) -> Self {
+		let src = unsafe { &*(src as *const BitSlice<C, T> as *const [()]) };
+		let (ptr, len) = match (src.as_ptr(), src.len()) {
+			(_, 0) => (NonNull::dangling(), 0),
+			(p, _) if p.is_null() => unreachable!(
+				"Slices cannot have a length when they begin at address 0"
+			),
+			(p, l) => (unsafe { NonNull::new_unchecked(p as *mut u8) }, l),
+		};
+		Self { ptr, len, _ty: PhantomData }
+	}
+}
+
+/// Produces the empty-slice representation.
+impl<T> Default for BitPtr<T>
+where T: Bits {
+	/// Produces an empty-slice representation.
+	///
+	/// The empty slice has no size or cursors, and its pointer is the alignment
+	/// of the type. The non-null pointer allows this structure to be null-value
+	/// optimized.
+	fn default() -> Self {
+		Self::empty()
+	}
+}
+
+/// Prints the `BitPtr` data structure for debugging.
+impl<T> Debug for BitPtr<T>
+where T: Bits {
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		struct HexPtr<T: Bits>(*const T);
+		impl<T: Bits> Debug for HexPtr<T> {
+			fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+				f.write_fmt(format_args!("0x{:0>1$X}", self.0 as usize, PTR_BITS >> 2))
+			}
+		}
+		struct HexAddr(usize);
+		impl Debug for HexAddr {
+			fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+				f.write_fmt(format_args!("{:#X}", self.0))
+			}
+		}
+		struct BinAddr<T: Bits>(BitIdx, PhantomData<T>);
+		impl<T: Bits>  Debug for BinAddr<T> {
+			fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+				f.write_fmt(format_args!("0b{:0>1$b}", *self.0, T::BITS as usize))
+			}
+		}
+		write!(f, "BitPtr<{}>", T::TYPENAME)?;
+		f.debug_struct("")
+			.field("data", &HexPtr::<T>(self.pointer()))
+			.field("elts", &HexAddr(self.elements()))
+			.field("head", &BinAddr::<T>(self.head(), PhantomData))
+			.field("tail", &BinAddr::<T>(self.tail(), PhantomData))
+			.finish()
+	}
+}
+
+#[cfg(test)]
+mod tests {
+	use super::*;
+
+	#[test]
+	fn associated_consts_u8() {
+		assert_eq!(BitPtr::<u8>::PTR_DATA_BITS, PTR_BITS);
+		assert_eq!(BitPtr::<u8>::PTR_HEAD_BITS, 0);
+		assert_eq!(BitPtr::<u8>::LEN_DATA_BITS, USZ_BITS - 6);
+		assert_eq!(BitPtr::<u8>::LEN_TAIL_BITS, 3);
+
+		assert_eq!(BitPtr::<u8>::PTR_DATA_MASK, !0);
+		assert_eq!(BitPtr::<u8>::PTR_HEAD_MASK, 0);
+		assert_eq!(BitPtr::<u8>::LEN_DATA_MASK, !0 << 6);
+		assert_eq!(BitPtr::<u8>::LEN_TAIL_MASK, 7 << 3);
+		assert_eq!(BitPtr::<u8>::LEN_INDX_MASK, 63);
+	}
+
+	#[test]
+	fn associated_consts_u16() {
+		assert_eq!(BitPtr::<u16>::PTR_DATA_BITS, PTR_BITS - 1);
+		assert_eq!(BitPtr::<u16>::PTR_HEAD_BITS, 1);
+		assert_eq!(BitPtr::<u16>::LEN_DATA_BITS, USZ_BITS - 7);
+		assert_eq!(BitPtr::<u16>::LEN_TAIL_BITS, 4);
+
+		assert_eq!(BitPtr::<u16>::PTR_DATA_MASK, !0 << 1);
+		assert_eq!(BitPtr::<u16>::PTR_HEAD_MASK, 1);
+		assert_eq!(BitPtr::<u16>::LEN_DATA_MASK, !0 << 7);
+		assert_eq!(BitPtr::<u16>::LEN_TAIL_MASK, 15 << 3);
+		assert_eq!(BitPtr::<u16>::LEN_INDX_MASK, 127);
+	}
+
+	#[test]
+	fn associated_consts_u32() {
+		assert_eq!(BitPtr::<u32>::PTR_DATA_BITS, PTR_BITS - 2);
+		assert_eq!(BitPtr::<u32>::PTR_HEAD_BITS, 2);
+		assert_eq!(BitPtr::<u32>::LEN_DATA_BITS, USZ_BITS - 8);
+		assert_eq!(BitPtr::<u32>::LEN_TAIL_BITS, 5);
+
+		assert_eq!(BitPtr::<u32>::PTR_DATA_MASK, !0 << 2);
+		assert_eq!(BitPtr::<u32>::PTR_HEAD_MASK, 3);
+		assert_eq!(BitPtr::<u32>::LEN_DATA_MASK, !0 << 8);
+		assert_eq!(BitPtr::<u32>::LEN_TAIL_MASK, 31 << 3);
+		assert_eq!(BitPtr::<u32>::LEN_INDX_MASK, 255);
+	}
+
+	#[test]
+	fn associated_consts_u64() {
+		assert_eq!(BitPtr::<u64>::PTR_DATA_BITS, PTR_BITS - 3);
+		assert_eq!(BitPtr::<u64>::PTR_HEAD_BITS, 3);
+		assert_eq!(BitPtr::<u64>::LEN_DATA_BITS, USZ_BITS - 9);
+		assert_eq!(BitPtr::<u64>::LEN_TAIL_BITS, 6);
+
+		assert_eq!(BitPtr::<u64>::PTR_DATA_MASK, !0 << 3);
+		assert_eq!(BitPtr::<u64>::PTR_HEAD_MASK, 7);
+		assert_eq!(BitPtr::<u64>::LEN_DATA_MASK, !0 << 9);
+		assert_eq!(BitPtr::<u64>::LEN_TAIL_MASK, 63 << 3);
+		assert_eq!(BitPtr::<u64>::LEN_INDX_MASK, 511);
+	}
+
+	#[test]
+	fn ctors() {
+		let data: [u32; 4] = [0x756c6153, 0x2c6e6f74, 0x6e6f6d20, 0x00216f64];
+		let bp = BitPtr::<u32>::new(&data as *const u32, 4, 0, 32);
+		assert_eq!(bp.pointer(), &data as *const u32);
+		assert_eq!(bp.elements(), 4);
+		assert_eq!(*bp.head(), 0);
+		assert_eq!(*bp.tail(), 32);
+	}
+
+	#[test]
+	fn empty() {
+		let data = [0u8; 4];
+		//  anything with 0 elements is unconditionally empty
+		assert!(BitPtr::<u8>::new(&data as *const u8, 0, 2, 4).is_empty());
+	}
+
+	#[test]
+	fn full() {
+		let elt_ct = BitPtr::<u64>::MAX_ELTS - 1;
+		//  maximum elements, maximum bits
+		let bp = BitPtr::<u64>::new(8 as *const u64, elt_ct, 0, 63);
+		assert!(bp.is_full());
+
+		//  one bit fewer
+		let bp = BitPtr::<u64>::new(8 as *const u64, elt_ct, 0, 62);
+		assert!(!bp.is_full());
+		assert_eq!(*bp.tail(), 62.into());
+
+		//  one element fewer
+		let bp = BitPtr::<u64>::new(8 as *const u64, elt_ct - 1, 0, 64);
+		assert!(!bp.is_full());
+	}
+
+	#[test]
+	#[should_panic]
+	fn overfull() {
+		BitPtr::<u64>::new(8 as *const u64, BitPtr::<u64>::MAX_ELTS - 1, 0, 64);
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/prelude.rs
@@ -0,0 +1,20 @@
+/*! `bitvec` Prelude
+
+!*/
+
+pub use crate::{
+	bitvec,
+	bits::Bits,
+	cursor::{
+		Cursor,
+		BigEndian,
+		LittleEndian,
+	},
+	slice::BitSlice,
+};
+
+#[cfg(feature = "alloc")]
+pub use crate::{
+	boxed::BitBox,
+	vec::BitVec,
+};
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/serdes.rs
@@ -0,0 +1,266 @@
+/*! `serde`-powered de/serialization
+
+!*/
+
+#![cfg(all(feature = "serdes"))]
+
+use crate::{
+	bits::Bits,
+	cursor::Cursor,
+	pointer::BitPtr,
+	slice::BitSlice,
+};
+
+#[cfg(feature = "alloc")]
+use crate::{
+	boxed::BitBox,
+	vec::BitVec,
+};
+
+use core::{
+	cmp,
+	fmt::{
+		self,
+		Formatter,
+	},
+	marker::PhantomData,
+	mem,
+};
+
+use serde::{
+	Serialize,
+	ser::{
+		Serializer,
+		SerializeStruct,
+	},
+};
+
+#[cfg(feature = "alloc")]
+use serde::{
+	Deserialize,
+	de::{
+		self,
+		Deserializer,
+		MapAccess,
+		SeqAccess,
+		Visitor,
+	},
+};
+
+/// A Serde visitor to pull `BitBox` data out of a serialized stream
+#[cfg(feature = "alloc")]
+#[derive(Clone, Copy, Default, Debug)]
+pub struct BitBoxVisitor<'de, C, T>
+where C: Cursor, T: Bits + Deserialize<'de> {
+	_cursor: PhantomData<C>,
+	_storage: PhantomData<&'de T>,
+}
+
+#[cfg(feature = "alloc")]
+impl<'de, C, T> BitBoxVisitor<'de, C, T>
+where C: Cursor, T: Bits + Deserialize<'de> {
+	fn new() -> Self {
+		BitBoxVisitor { _cursor: PhantomData, _storage: PhantomData }
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<'de, C, T> Visitor<'de> for BitBoxVisitor<'de, C, T>
+where C: Cursor, T: Bits + Deserialize<'de> {
+	type Value = BitBox<C, T>;
+
+	fn expecting(&self, fmt: &mut Formatter) -> fmt::Result {
+		fmt.write_str("A BitSet data series")
+	}
+
+	/// Visit a sequence of anonymous data elements. These must be in the order
+	/// `usize', `u8`, `u8`, `[T]`.
+	fn visit_seq<V>(self, mut seq: V) -> Result<Self::Value, V::Error>
+	where V: SeqAccess<'de> {
+		let elts: usize = seq.next_element()?
+			.ok_or_else(|| de::Error::invalid_length(0, &self))?;
+		let head: u8 = seq.next_element()?
+			.ok_or_else(|| de::Error::invalid_length(1, &self))?;
+		let tail: u8 = seq.next_element()?
+			.ok_or_else(|| de::Error::invalid_length(2, &self))?;
+		let data: Box<[T]> = seq.next_element()?
+			.ok_or_else(|| de::Error::invalid_length(3, &self))?;
+
+		let bitptr = BitPtr::new(data.as_ptr(), cmp::min(elts, data.len()), head, tail);
+		mem::forget(data);
+		Ok(unsafe { BitBox::from_raw(bitptr) })
+	}
+
+	/// Visit a map of named data elements. These may be in any order, and must
+	/// be the pairs `elts: usize`, `head: u8`, `tail: u8`, and `data: [T]`.
+	fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error>
+	where V: MapAccess<'de> {
+		let mut elts: Option<usize> = None;
+		let mut head: Option<u8> = None;
+		let mut tail: Option<u8> = None;
+		let mut data: Option<Box<[T]>> = None;
+
+		while let Some(key) = map.next_key()? {
+			match key {
+				"elts" => if elts.replace(map.next_value()?).is_some() {
+					return Err(de::Error::duplicate_field("elts"));
+				},
+				"head" => if head.replace(map.next_value()?).is_some() {
+					return Err(de::Error::duplicate_field("head"));
+				},
+				"tail" => if tail.replace(map.next_value()?).is_some() {
+					return Err(de::Error::duplicate_field("tail"));
+				},
+				"data" => if data.replace(map.next_value()?).is_some() {
+					return Err(de::Error::duplicate_field("data"));
+				},
+				f => return Err(de::Error::unknown_field(
+					f, &["elts", "head", "tail", "data"]
+				)),
+			}
+		}
+		let elts = elts.ok_or_else(|| de::Error::missing_field("elts"))?;
+		let head = head.ok_or_else(|| de::Error::missing_field("head"))?;
+		let tail = tail.ok_or_else(|| de::Error::missing_field("tail"))?;
+		let data = data.ok_or_else(|| de::Error::missing_field("data"))?;
+
+		let bitptr = BitPtr::new(
+			data.as_ptr(),
+			cmp::min(elts as usize, data.len()),
+			head,
+			tail,
+		);
+		mem::forget(data);
+		Ok(unsafe { BitBox::from_raw(bitptr) })
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<'de, C, T> Deserialize<'de> for BitBox<C, T>
+where C: Cursor, T: 'de + Bits + Deserialize<'de> {
+	fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+	where D: Deserializer<'de> {
+		deserializer.deserialize_struct("BitSet", &[
+			"elts", "head", "tail", "data",
+		], BitBoxVisitor::new())
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<'de, C, T> Deserialize<'de> for BitVec<C, T>
+where C: Cursor, T: 'de + Bits + Deserialize<'de> {
+	fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+	where D: Deserializer<'de> {
+		BitBox::deserialize(deserializer).map(Into::into)
+	}
+}
+
+impl<C, T> Serialize for BitSlice<C, T>
+where C: Cursor, T: Bits + Serialize {
+	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+	where S: Serializer {
+		let (e, h, t) = self.bitptr().region_data();
+		let mut state = serializer.serialize_struct("BitSet", 4)?;
+
+		state.serialize_field("elts", &(e as u64))?;
+		state.serialize_field("head", &*h)?;
+		state.serialize_field("tail", &*t)?;
+		state.serialize_field("data", self.as_ref())?;
+
+		state.end()
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<C, T> Serialize for BitBox<C, T>
+where C: Cursor, T: Bits + Serialize {
+	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+	where S: Serializer {
+		BitSlice::serialize(&*self, serializer)
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<C, T> Serialize for BitVec<C, T>
+where C: Cursor, T: Bits + Serialize {
+	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+	where S: Serializer {
+		BitSlice::serialize(&*self, serializer)
+	}
+}
+
+#[cfg(test)]
+mod tests {
+	use crate::prelude::*;
+	use serde_test::{
+		Token,
+		assert_de_tokens,
+		assert_ser_tokens,
+		assert_tokens,
+	};
+
+	macro_rules! bvtok {
+		( s $elts:expr, $head:expr, $tail:expr, $len:expr, $ty:ident $( , $data:expr )* ) => {
+			&[
+				Token::Struct { name: "BitSet", len: 4, },
+				Token::Str("elts"), Token::U64( $elts ),
+				Token::Str("head"), Token::U8( $head ),
+				Token::Str("tail"), Token::U8( $tail ),
+				Token::Str("data"), Token::Seq { len: Some( $len ) },
+				$( Token:: $ty ( $data ), )*
+				Token::SeqEnd,
+				Token::StructEnd,
+			]
+		};
+		( d $elts:expr, $head:expr, $tail:expr, $len:expr, $ty:ident $( , $data:expr )* ) => {
+			&[
+				Token::Struct { name: "BitSet", len: 4, },
+				Token::BorrowedStr("elts"), Token::U64( $elts ),
+				Token::BorrowedStr("head"), Token::U8( $head ),
+				Token::BorrowedStr("tail"), Token::U8( $tail ),
+				Token::BorrowedStr("data"), Token::Seq { len: Some( $len ) },
+				$( Token:: $ty ( $data ), )*
+				Token::SeqEnd,
+				Token::StructEnd,
+			]
+		};
+	}
+
+	#[test]
+	fn empty() {
+		let slice = BitSlice::<BigEndian, u8>::empty();
+		//  TODO(myrrlyn): Refactor BitPtr impl so the empty slice is 0/0
+		assert_ser_tokens(&slice, bvtok![s 0, 0, 8, 0, U8]);
+		assert_de_tokens(&bitvec![], bvtok![ d 0, 0, 8, 0, U8 ]);
+	}
+
+	#[test]
+	fn small() {
+		let bv = bitvec![1; 5];
+		eprintln!("made vec");
+		let bs = &bv[1 ..];
+		assert_ser_tokens(&bs, bvtok![s 1, 1, 5, 1, U8, 0b1111_1000]);
+
+		let bv = bitvec![LittleEndian, u16; 1; 12];
+		assert_ser_tokens(&bv, bvtok![s 1, 0, 12, 1, U16, 0b00001111_11111111]);
+
+		let bb: BitBox<_, _> = bitvec![LittleEndian, u32; 1; 10].into();
+		assert_ser_tokens(&bb, bvtok![s 1, 0, 10, 1, U32, 0x00_00_03_FF]);
+	}
+
+	#[test]
+	fn wide() {
+		let src: &[u8] = &[0, !0];
+		let bs: &BitSlice = src.into();
+		assert_ser_tokens(&(&bs[1 .. 15]), bvtok![s 2, 1, 7, 2, U8, 0, !0]);
+	}
+
+	#[test]
+	fn deser() {
+		let bv = bitvec![0, 1, 1, 0, 1, 0];
+		assert_de_tokens(&bv, bvtok![d 1, 0, 6, 1, U8, 0b0110_1000]);
+		//  test that the bits outside the bits domain don't matter in deser
+		assert_de_tokens(&bv, bvtok![d 1, 0, 6, 1, U8, 0b0110_1010]);
+		assert_de_tokens(&bv, bvtok![d 1, 0, 6, 1, U8, 0b0110_1001]);
+	}
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/bitvec/src/slice.rs
@@ -0,0 +1,5239 @@
+/*! `BitSlice` Wide Reference
+
+This module defines semantic operations on `[u1]`, in contrast to the mechanical
+operations defined in `BitPtr`.
+
+The `&BitSlice` handle has the same size and general layout as the standard Rust
+slice handle `&[T]`. Its binary layout is wholly incompatible with the layout of
+Rust slices, and must never be interchanged except through the provided APIs.
+!*/
+
+use crate::{
+	bits::Bits,
+	cursor::{
+		BigEndian,
+		Cursor,
+	},
+	domain::*,
+	pointer::BitPtr,
+};
+use core::{
+	cmp::{
+		Eq,
+		Ord,
+		Ordering,
+		PartialEq,
+		PartialOrd,
+	},
+	convert::{
+		AsMut,
+		AsRef,
+		From,
+	},
+	fmt::{
+		self,
+		Debug,
+		DebugList,
+		Display,
+		Formatter,
+	},
+	hash::{
+		Hash,
+		Hasher,
+	},
+	iter::{
+		DoubleEndedIterator,
+		ExactSizeIterator,
+		FusedIterator,
+		Iterator,
+		IntoIterator,
+	},
+	marker::PhantomData,
+	mem,
+	ops::{
+		AddAssign,
+		BitAndAssign,
+		BitOrAssign,
+		BitXorAssign,
+		Index,
+		IndexMut,
+		Neg,
+		Not,
+		Range,
+		RangeFrom,
+		RangeFull,
+		RangeInclusive,
+		RangeTo,
+		RangeToInclusive,
+		ShlAssign,
+		ShrAssign,
+	},
+	ptr,
+	slice,
+	str,
+};
+
+#[cfg(feature = "alloc")]
+use crate::vec::BitVec;
+
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::borrow::ToOwned;
+
+#[cfg(feature = "std")]
+use std::borrow::ToOwned;
+
+/** A compact slice of bits, whose cursor and storage types can be customized.
+
+`BitSlice` is a newtype wrapper over [`[()]`], with a specialized reference
+handle. As an unsized slice, it can only ever be held by reference. The
+reference type is **binary incompatible** with any other Rust slice handles.
+
+`BitSlice` can only be dynamically allocated by this library. Creation of any
+other `BitSlice` collections will result in catastrophically incorrect behavior.
+
+A `BitSlice` reference can be created through the [`bitvec!`] macro, from a
+[`BitVec`] collection, or from any slice of elements by using the appropriate
+[`From`] implementation.
+
+`BitSlice`s are a view into a block of memory at bit-level resolution. They are
+represented by a crate-internal pointer structure that ***cannot*** be used with
+other Rust code except through the provided conversion APIs.
+
+```rust
+use bitvec::prelude::*;
+
+let store: &[u8] = &[0x69];
+//  slicing a bitvec
+let bslice: &BitSlice = store.into();
+//  coercing an array to a bitslice
+let bslice: &BitSlice = (&[1u8, 254u8][..]).into();
+```
+
+Bit slices are either mutable or shared. The shared slice type is
+`&BitSlice<C, T>`, while the mutable slice type is `&mut BitSlice<C, T>`. For
+example, you can mutate bits in the memory to which a mutable `BitSlice` points:
+
+```rust
+use bitvec::prelude::*;
+let mut base = [0u8, 0, 0, 0];
+{
+ let bs: &mut BitSlice = (&mut base[..]).into();
+ bs.set(13, true);
+ eprintln!("{:?}", bs.as_ref());
+ assert!(bs[13]);
+}
+assert_eq!(base[1], 4);
+```
+
+# Type Parameters
+
+- `C: Cursor`: An implementor of the `Cursor` trait. This type is used to
+  convert semantic indices into concrete bit positions in elements, and store or
+  retrieve bit values from the storage type.
+- `T: Bits`: An implementor of the `Bits` trait: `u8`, `u16`, `u32`, `u64`. This
+  is the actual type in memory the slice will use to store data.
+
+# Safety
+
+The `&BitSlice` reference handle has the same *size* as standard Rust slice
+handles, but it is ***extremely binary incompatible*** with them. Attempting to
+treat `&BitSlice<_, T>` as `&[T]` in any manner except through the provided APIs
+is ***catastrophically*** unsafe and unsound.
+
+[`BitVec`]: ../struct.BitVec.html
+[`From`]: https://doc.rust-lang.org/stable/std/convert/trait.From.html
+[`bitvec!`]: ../macro.bitvec.html
+[`[()]`]: https://doc.rust-lang.org/stable/std/primitive.slice.html
+**/
+#[repr(transparent)]
+pub struct BitSlice<C = BigEndian, T = u8>
+where C: Cursor, T: Bits {
+	/// Cursor type for selecting bits inside an element.
+	_kind: PhantomData<C>,
+	/// Element type of the slice.
+	///
+	/// eddyb recommends using `PhantomData<T>` and `[()]` instead of `[T]`
+	/// alone.
+	_type: PhantomData<T>,
+	/// Slice of elements `T` over which the `BitSlice` has usage.
+	_elts: [()],
+}
+
+impl<C, T> BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Produces the empty slice. This is equivalent to `&[]` for Rust slices.
+	///
+	/// # Returns
+	///
+	/// An empty `&BitSlice` handle.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let bv: &BitSlice = BitSlice::empty();
+	/// ```
+	pub fn empty<'a>() -> &'a Self {
+		BitPtr::empty().into()
+	}
+
+	/// Produces the empty mutable slice. This is equivalent to `&mut []` for
+	/// Rust slices.
+	///
+	/// # Returns
+	///
+	/// An empty `&mut BitSlice` handle.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let bv: &mut BitSlice = BitSlice::empty_mut();
+	/// ```
+	pub fn empty_mut<'a>() -> &'a mut Self {
+		BitPtr::empty().into()
+	}
+
+	/// Returns the number of bits contained in the `BitSlice`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of live bits in the slice domain.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.len(), 8);
+	/// ```
+	pub fn len(&self) -> usize {
+		self.bitptr().bits()
+	}
+
+	/// Tests if the slice is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether the slice has no live bits.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let bv: &BitSlice = BitSlice::empty();
+	/// assert!(bv.is_empty());
+	/// let bv: &BitSlice = (&[0u8] as &[u8]).into();;
+	/// assert!(!bv.is_empty());
+	/// ```
+	pub fn is_empty(&self) -> bool {
+		self.len() == 0
+	}
+
+	/// Gets the first element of the slice, if present.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// `None` if the slice is empty, or `Some(bit)` if it is not.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// assert!(BitSlice::<BigEndian, u8>::empty().first().is_none());
+	/// let bv: &BitSlice = (&[128u8] as &[u8]).into();
+	/// assert!(bv.first().unwrap());
+	/// ```
+	pub fn first(&self) -> Option<bool> {
+		if self.is_empty() { None }
+		else { Some(self[0]) }
+	}
+
+	/// Returns the first and all the rest of the bits of the slice, or `None`
+	/// if it is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// If the slice is empty, this returns `None`, otherwise, it returns `Some`
+	/// of:
+	///
+	/// - the first bit
+	/// - a `&BitSlice` of all the rest of the bits (this may be empty)
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// assert!(BitSlice::<BigEndian, u8>::empty().split_first().is_none());
+	///
+	/// let store: &[u8] = &[128];
+	/// let bv: &BitSlice = store.into();
+	/// let (h, t) = bv.split_first().unwrap();
+	/// assert!(h);
+	/// assert!(t.not_any());
+	///
+	/// let bv = &bv[0 .. 1];
+	/// let (h, t) = bv.split_first().unwrap();
+	/// assert!(h);
+	/// assert!(t.is_empty());
+	/// ```
+	pub fn split_first(&self) -> Option<(bool, &Self)> {
+		if self.is_empty() { None }
+		else { Some((self[0], &self[1 ..])) }
+	}
+
+	/// Returns the first and all the rest of the bits of the slice, or `None`
+	/// if it is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// If the slice is empty, this returns `None`, otherwise, it returns `Some`
+	/// of:
+	///
+	/// - the first bit
+	/// - a `&mut BitSlice` of all the rest of the bits (this may be empty)
+	pub fn split_first_mut(&mut self) -> Option<(bool, &mut Self)> {
+		if self.is_empty() { None }
+		else { Some((self[0], &mut self[1 ..])) }
+	}
+
+	/// Returns the last and all the rest of the bits in the slice, or `None`
+	/// if it is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// If the slice is empty, this returns `None`, otherwise, it returns `Some`
+	/// of:
+	///
+	/// - the last bit
+	/// - a `&BitSlice` of all the rest of the bits (this may be empty)
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// assert!(BitSlice::<BigEndian, u8>::empty().split_last().is_none());
+	///
+	/// let bv: &BitSlice = (&[1u8] as &[u8]).into();
+	/// let (t, h) = bv.split_last().unwrap();
+	/// assert!(t);
+	/// assert!(h.not_any());
+	///
+	/// let bv = &bv[7 .. 8];
+	/// let (t, h) = bv.split_last().unwrap();
+	/// assert!(t);
+	/// assert!(h.is_empty());
+	/// ```
+	pub fn split_last(&self) -> Option<(bool, &Self)> {
+		if self.is_empty() { None }
+		else {
+			let len = self.len();
+			Some((self[len - 1], &self[.. len - 1]))
+		}
+	}
+
+	/// Returns the last and all the rest of the bits in the slice, or `None`
+	/// if it is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// If the slice is empty, this returns `None`, otherwise, it returns `Some`
+	/// of:
+	///
+	/// - the last bit
+	/// - a `&BitSlice` of all the rest of the bits (this may be empty)
+	pub fn split_last_mut(&mut self) -> Option<(bool, &mut Self)> {
+		if self.is_empty() { None }
+		else {
+			let len = self.len();
+			Some((self[len - 1], &mut self[.. len - 1]))
+		}
+	}
+
+	/// Gets the last element of the slice, or `None` if it is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// `None` if the slice is empty, or `Some(bit)` if it is not.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// assert!(BitSlice::<BigEndian, u8>::empty().last().is_none());
+	/// let bv: &BitSlice = (&[1u8] as &[u8]).into();
+	/// assert!(bv.last().unwrap());
+	/// ```
+	pub fn last(&self) -> Option<bool> {
+		if self.is_empty() { None }
+		else { Some(self[self.len() - 1]) }
+	}
+
+	/// Gets the bit value at the given position.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `index`: The bit index to retrieve.
+	///
+	/// # Returns
+	///
+	/// The bit at the specified index, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let bv: &BitSlice = (&[8u8] as &[u8]).into();
+	/// assert!(bv.get(4).unwrap());
+	/// assert!(!bv.get(3).unwrap());
+	/// assert!(bv.get(10).is_none());
+	/// ```
+	pub fn get(&self, index: usize) -> Option<bool> {
+		if index >= self.len() { None }
+		else { Some(self[index]) }
+	}
+
+	/// Sets the bit value at the given position.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `index`: The bit index to set. It must be in the domain
+	///   `0 .. self.len()`.
+	/// - `value`: The value to be set, `true` for `1` and `false` for `0`.
+	///
+	/// # Panics
+	///
+	/// This method panics if `index` is outside the slice domain.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [8u8];
+	/// let bv: &mut BitSlice = store.into();
+	/// assert!(!bv[3]);
+	/// bv.set(3, true);
+	/// assert!(bv[3]);
+	/// ```
+	pub fn set(&mut self, index: usize, value: bool) {
+		let len = self.len();
+		assert!(index < len, "Index out of range: {} >= {}", index, len);
+
+		let h = self.bitptr().head();
+		//  Find the index of the containing element, and of the bit within it.
+		let (elt, bit) = h.offset::<T>(index as isize);
+		self.as_mut()[elt as usize].set::<C>(bit, value);
+	}
+
+	/// Retrieves a read pointer to the start of the underlying data slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A pointer to the first element, partial or not, in the underlying store.
+	///
+	/// # Safety
+	///
+	/// The caller must ensure that the slice outlives the pointer this function
+	/// returns, or else it will dangle and point to garbage.
+	///
+	/// Modifying the container referenced by this slice may cause its buffer to
+	/// reallocate, which would also make any pointers to it invalid.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0; 4];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(store.as_ptr(), bv.as_ptr());
+	/// ```
+	pub fn as_ptr(&self) -> *const T {
+		self.bitptr().pointer()
+	}
+
+	/// Retrieves a write pointer to the start of the underlying data slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// A pointer to the first element, partial or not, in the underlying store.
+	///
+	/// # Safety
+	///
+	/// The caller must ensure that the slice outlives the pointer this function
+	/// returns, or else it will dangle and point to garbage.
+	///
+	/// Modifying the container referenced by this slice may cause its buffer to
+	/// reallocate, which would also make any pointers to it invalid.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut[0; 4];
+	/// let store_ptr = store.as_mut_ptr();
+	/// let bv: &mut BitSlice = store.into();
+	/// assert_eq!(store_ptr, bv.as_mut_ptr());
+	/// ```
+	pub fn as_mut_ptr(&mut self) -> *mut T {
+		self.bitptr().pointer() as *mut T
+	}
+
+	/// Swaps two bits in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `a`: The first index to be swapped.
+	/// - `b`: The second index to be swapped.
+	///
+	/// # Panics
+	///
+	/// Panics if either `a` or `b` are out of bounds.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut[32u8];
+	/// let bv: &mut BitSlice = store.into();
+	/// assert!(!bv[0]);
+	/// assert!(bv[2]);
+	/// bv.swap(0, 2);
+	/// assert!(bv[0]);
+	/// assert!(!bv[2]);
+	/// ```
+	pub fn swap(&mut self, a: usize, b: usize) {
+		assert!(a < self.len(), "Index {} out of bounds: {}", a, self.len());
+		assert!(b < self.len(), "Index {} out of bounds: {}", b, self.len());
+		let bit_a = self[a];
+		let bit_b = self[b];
+		self.set(a, bit_b);
+		self.set(b, bit_a);
+	}
+
+	/// Reverses the order of bits in the slice, in place.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut[0b1010_1010];
+	/// {
+	///   let bv: &mut BitSlice = store.into();
+	///   bv[1 .. 7].reverse();
+	/// }
+	/// eprintln!("{:b}", store[0]);
+	/// assert_eq!(store[0], 0b1101_0100);
+	/// ```
+	pub fn reverse(&mut self) {
+		//  this is better implemented as a recursive algorithm, but Rust
+		//  doesn’t yet flatten recursive tail calls into a loop, so, do it
+		//  manually.
+		let mut cur: &mut Self = self;
+		loop {
+			let len = cur.len();
+			if len < 2 {
+				return;
+			}
+			//  swap() has two assertions on each call, that reverse() knows it
+			//  can bypass
+			let (h, t) = (cur[0], cur[len - 1]);
+			cur.set(0, t);
+			cur.set(len - 1, h);
+			cur = &mut cur[1 .. len - 1];
+		}
+	}
+
+	/// Provides read-only iteration across the slice domain.
+	///
+	/// The iterator returned from this method implements `ExactSizeIterator`
+	/// and `DoubleEndedIterator` just as the consuming `.into_iter()` method’s
+	/// iterator does.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An iterator over all bits in the slice domain, in `C` and `T` ordering.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[64];
+	/// let bv: &BitSlice = store.into();
+	/// let mut iter = bv[.. 2].iter();
+	/// assert!(!iter.next().unwrap());
+	/// assert!(iter.next().unwrap());
+	/// assert!(iter.next().is_none());
+	/// ```
+	pub fn iter(&self) -> Iter<C, T> {
+		self.into_iter()
+	}
+
+	/// Produces a sliding iterator over consecutive windows in the slice. Each
+	/// windows has the width `size`. The windows overlap. If the slice is
+	/// shorter than `size`, the produced iterator is empty.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `size`: The width of each window.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields sliding views into the slice.
+	///
+	/// # Panics
+	///
+	/// This function panics if the `size` is zero.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0100_1011];
+	/// let bv: &BitSlice = store.into();
+	/// let mut windows = bv.windows(4);
+	/// assert_eq!(windows.next(), Some(&bv[0 .. 4]));
+	/// assert_eq!(windows.next(), Some(&bv[1 .. 5]));
+	/// assert_eq!(windows.next(), Some(&bv[2 .. 6]));
+	/// assert_eq!(windows.next(), Some(&bv[3 .. 7]));
+	/// assert_eq!(windows.next(), Some(&bv[4 .. 8]));
+	/// assert!(windows.next().is_none());
+	/// ```
+	pub fn windows(&self, size: usize) -> Windows<C, T> {
+		assert_ne!(size, 0, "Window width cannot be zero");
+		Windows {
+			inner: self,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice. Each
+	/// chunk, except possibly the last, has the width `size`. The chunks do not
+	/// overlap. If the slice is shorter than `size`, the produced iterator
+	/// produces only one chunk.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive chunks of the slice.
+	///
+	/// # Panics
+	///
+	/// This function panics if the `size` is zero.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0100_1011];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks = bv.chunks(3);
+	/// assert_eq!(chunks.next(), Some(&bv[0 .. 3]));
+	/// assert_eq!(chunks.next(), Some(&bv[3 .. 6]));
+	/// assert_eq!(chunks.next(), Some(&bv[6 .. 8]));
+	/// assert!(chunks.next().is_none());
+	/// ```
+	pub fn chunks(&self, size: usize) -> Chunks<C, T> {
+		assert_ne!(size, 0, "Chunk width cannot be zero");
+		Chunks {
+			inner: self,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice. Each
+	/// chunk, except possibly the last, has the width `size`. The chunks do not
+	/// overlap. If the slice is shorter than `size`, the produced iterator
+	/// produces only one chunk.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive mutable chunks of the slice.
+	///
+	/// # Panics
+	///
+	/// This function panics if the `size` is zero.
+	pub fn chunks_mut(&mut self, size: usize) -> ChunksMut<C, T> {
+		assert_ne!(size, 0, "Chunk width cannot be zero");
+		ChunksMut {
+			inner: self,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice. Each
+	/// chunk has the width `size`. If `size` does not evenly divide the slice,
+	/// then the remainder is not part of the iteration, and can be accessed
+	/// separately with the `.remainder()` method.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive chunks of the slice.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0100_1011];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks_exact = bv.chunks_exact(3);
+	/// assert_eq!(chunks_exact.next(), Some(&bv[0 .. 3]));
+	/// assert_eq!(chunks_exact.next(), Some(&bv[3 .. 6]));
+	/// assert!(chunks_exact.next().is_none());
+	/// assert_eq!(chunks_exact.remainder(), &bv[6 .. 8]);
+	/// ```
+	pub fn chunks_exact(&self, size: usize) -> ChunksExact<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		let rem = self.len() % size;
+		let len = self.len() - rem;
+		let (inner, extra) = self.split_at(len);
+		ChunksExact {
+			inner,
+			extra,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice. Each
+	/// chunk has the width `size`. If `size` does not evenly divide the slice,
+	/// then the remainder is not part of the iteration, and can be accessed
+	/// separately with the `.remainder()` method.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive mutable chunks of the slice.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	pub fn chunks_exact_mut(&mut self, size: usize) -> ChunksExactMut<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		let rem = self.len() % size;
+		let len = self.len() - rem;
+		let (inner, extra) = self.split_at_mut(len);
+		ChunksExactMut {
+			inner,
+			extra,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice, from
+	/// the back to the front. Each chunk, except possibly the front, has the
+	/// width `size`. The chunks do not overlap. If the slice is shorter than
+	/// `size`, then the iterator produces one item.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive chunks of the slice, from the back
+	/// to the front.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0100_1011];
+	/// let bv: &BitSlice = store.into();
+	/// let mut rchunks = bv.rchunks(3);
+	/// assert_eq!(rchunks.next(), Some(&bv[5 .. 8]));
+	/// assert_eq!(rchunks.next(), Some(&bv[2 .. 5]));
+	/// assert_eq!(rchunks.next(), Some(&bv[0 .. 2]));
+	/// assert!(rchunks.next().is_none());
+	/// ```
+	pub fn rchunks(&self, size: usize) -> RChunks<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		RChunks {
+			inner: self,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice, from
+	/// the back to the front. Each chunk, except possibly the front, has the
+	/// width `size`. The chunks do not overlap. If the slice is shorter than
+	/// `size`, then the iterator produces one item.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive mutable chunks of the slice, from
+	/// the back to the front.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	pub fn rchunks_mut(&mut self, size: usize) -> RChunksMut<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		RChunksMut {
+			inner: self,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice, from
+	/// the back to the front. Each chunk has the width `size`. If `size` does
+	/// not evenly divide the slice, then the remainder is not part of the
+	/// iteration, and can be accessed separately with the `.remainder()`
+	/// method.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive chunks of the slice, from the back
+	/// to the front.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0100_1011];
+	/// let bv: &BitSlice = store.into();
+	/// let mut rchunks_exact = bv.rchunks_exact(3);
+	/// assert_eq!(rchunks_exact.next(), Some(&bv[5 .. 8]));
+	/// assert_eq!(rchunks_exact.next(), Some(&bv[2 .. 5]));
+	/// assert!(rchunks_exact.next().is_none());
+	/// assert_eq!(rchunks_exact.remainder(), &bv[0 .. 2]);
+	/// ```
+	pub fn rchunks_exact(&self, size: usize) -> RChunksExact<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		let (extra, inner) = self.split_at(self.len() % size);
+		RChunksExact {
+			inner,
+			extra,
+			width: size,
+		}
+	}
+
+	/// Produces a galloping iterator over consecutive chunks in the slice, from
+	/// the back to the front. Each chunk has the width `size`. If `size` does
+	/// not evenly divide the slice, then the remainder is not part of the
+	/// iteration, and can be accessed separately with the `.remainder()`
+	/// method.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `size`: The width of each chunk.
+	///
+	/// # Returns
+	///
+	/// An iterator which yields consecutive mutable chunks of the slice, from
+	/// the back to the front.
+	///
+	/// # Panics
+	///
+	/// This function panics if `size` is zero.
+	pub fn rchunks_exact_mut(&mut self, size: usize) -> RChunksExactMut<C, T> {
+		assert_ne!(size, 0, "Chunk size cannot be zero");
+		let (extra, inner) = self.split_at_mut(self.len() % size);
+		RChunksExactMut {
+			inner,
+			extra,
+			width: size,
+		}
+	}
+
+	/// Divides one slice into two at an index.
+	///
+	/// The first will contain all indices from `[0, mid)` (excluding the index
+	/// `mid` itself) and the second will contain all indices from `[mid, len)`
+	/// (excluding the index `len` itself).
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `mid`: The index at which to split
+	///
+	/// # Returns
+	///
+	/// - The bits up to but not including `mid`.
+	/// - The bits from mid onwards.
+	///
+	/// # Panics
+	///
+	/// Panics if `mid > self.len()`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x0F];
+	/// let bv: &BitSlice = store.into();
+	///
+	/// let (l, r) = bv.split_at(0);
+	/// assert!(l.is_empty());
+	/// assert_eq!(r, bv);
+	///
+	/// let (l, r) = bv.split_at(4);
+	/// assert_eq!(l, &bv[0 .. 4]);
+	/// assert_eq!(r, &bv[4 .. 8]);
+	///
+	/// let (l, r) = bv.split_at(8);
+	/// assert_eq!(l, bv);
+	/// assert!(r.is_empty());
+	/// ```
+	pub fn split_at(&self, mid: usize) -> (&Self, &Self) {
+		assert!(mid <= self.len(), "Index {} out of bounds: {}", mid, self.len());
+		if mid == self.len() {
+			(&self, Self::empty())
+		}
+		else {
+			(&self[.. mid], &self[mid ..])
+		}
+	}
+
+	/// Divides one slice into two at an index.
+	///
+	/// The first will contain all indices from `[0, mid)` (excluding the index
+	/// `mid` itself) and the second will contain all indices from `[mid, len)`
+	/// (excluding the index `len` itself).
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `mid`: The index at which to split
+	///
+	/// # Returns
+	///
+	/// - The bits up to but not including `mid`.
+	/// - The bits from mid onwards.
+	///
+	/// # Panics
+	///
+	/// Panics if `mid > self.len()`.
+	pub fn split_at_mut(&mut self, mid: usize) -> (&mut Self, &mut Self) {
+		let (head, tail) = self.split_at(mid);
+		let h_mut = {
+			let (p, e, h, t) = head.bitptr().raw_parts();
+			BitPtr::new(p, e, h, t)
+		};
+		let t_mut = {
+			let (p, e, h, t) = tail.bitptr().raw_parts();
+			BitPtr::new(p, e, h, t)
+		};
+		(h_mut.into(), t_mut.into())
+	}
+
+	/// Tests if the slice begins with the given prefix.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `prefix`: Any `BitSlice` against which `self` is tested. This is not
+	///   required to have the same cursor or storage types as `self`.
+	///
+	/// # Returns
+	///
+	/// Whether `self` begins with `prefix`. This is true only if `self` is at
+	/// least as long as `prefix` and their bits are semantically equal.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xA6];
+	/// let bv: &BitSlice = store.into();;
+	/// assert!(bv.starts_with(&bv[.. 3]));
+	/// assert!(!bv.starts_with(&bv[3 ..]));
+	/// ```
+	pub fn starts_with<D, U>(&self, prefix: &BitSlice<D, U>) -> bool
+	where D: Cursor, U: Bits {
+		let plen = prefix.len();
+		self.len() >= plen && prefix == &self[.. plen]
+	}
+
+	/// Tests if the slice ends with the given suffix.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `suffix`: Any `BitSlice` against which `self` is tested. This is not
+	///   required to have the same cursor or storage types as `self`.
+	///
+	/// # Returns
+	///
+	/// Whether `self` ends with `suffix`. This is true only if `self` is at
+	/// least as long as `suffix` and their bits are semantically equal.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xA6];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(bv.ends_with(&bv[5 ..]));
+	/// assert!(!bv.ends_with(&bv[.. 5]));
+	/// ```
+	pub fn ends_with<D, U>(&self, suffix: &BitSlice<D, U>) -> bool
+	where D: Cursor, U: Bits {
+		let slen = suffix.len();
+		let len = self.len();
+		len >= slen && suffix == &self[len - slen ..]
+	}
+
+	/// Rotates the slice, in place, to the left.
+	///
+	/// After calling this method, the bits from `[.. by]` will be at the back
+	/// of the slice, and the bits from `[by ..]` will be at the front. This
+	/// operates fully in-place.
+	///
+	/// In-place rotation of bits requires this method to take `O(k × n)` time.
+	/// It is impossible to use machine intrinsics to perform galloping rotation
+	/// on bits.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `by`: The number of bits by which to rotate left. This must be in the
+	///   range `0 ..= self.len()`. If it is `0` or `self.len()`, then this
+	///   method is a no-op.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0xF0];
+	/// let bv: &mut BitSlice = store.into();
+	/// bv.rotate_left(2);
+	/// assert_eq!(bv.as_ref()[0], 0xC3);
+	/// ```
+	pub fn rotate_left(&mut self, by: usize) {
+		let len = self.len();
+		assert!(by <= len, "Slices cannot be rotated by more than their length");
+		if by == 0 || by == len {
+			return;
+		}
+
+		for _ in 0 .. by {
+			let tmp = self[0];
+			for n in 1 .. len {
+				let bit = self[n];
+				self.set(n - 1, bit);
+			}
+			self.set(len - 1, tmp);
+		}
+	}
+
+	/// Rotates the slice, in place, to the right.
+	///
+	/// After calling this method, the bits from `[self.len() - by ..]` will be
+	/// at the front of the slice, and the bits from `[.. self.len() - by]` will
+	/// be at the back. This operates fully in-place.
+	///
+	/// In-place rotation of bits requires this method to take `O(k × n)` time.
+	/// It is impossible to use machine intrinsics to perform galloping rotation
+	/// on bits.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `by`: The number of bits by which to rotate right. This must be in the
+	///   range `0 ..= self.len()`. If it is `0` or `self.len`, then this method
+	///   is a no-op.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0xF0];
+	/// let bv: &mut BitSlice = store.into();
+	/// bv.rotate_right(2);
+	/// assert_eq!(bv.as_ref()[0], 0x3C);
+	/// ```
+	pub fn rotate_right(&mut self, by: usize) {
+		let len = self.len();
+		assert!(by <= len, "Slices cannot be rotated by more than their length");
+		if by == len {
+			return;
+		}
+
+		//  Perform `by` repetitions,
+		for _ in 0 .. by {
+			let tmp = self[len - 1];
+			//  of `len` steps
+			for n in (0 .. len - 1).rev() {
+				let bit = self[n];
+				self.set(n + 1, bit);
+			}
+			self.set(0, tmp);
+		}
+	}
+
+	/// Tests if *all* bits in the slice domain are set (logical `∧`).
+	///
+	/// # Truth Table
+	///
+	/// ```text
+	/// 0 0 => 0
+	/// 0 1 => 0
+	/// 1 0 => 0
+	/// 1 1 => 1
+	/// ```
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether all bits in the slice domain are set.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xFD];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(bv[.. 4].all());
+	/// assert!(!bv[4 ..].all());
+	/// ```
+	pub fn all(&self) -> bool {
+		match self.bitptr().domain() {
+			BitDomain::Empty => return false,
+			BitDomain::Minor(head, elt, tail) =>  {
+				for n in *head .. *tail {
+					if !elt.get::<C>(n.into()) {
+						return false;
+					}
+				}
+			},
+			BitDomain::Major(h, head, body, tail, t) => {
+				for n in *h .. T::SIZE {
+					if !head.get::<C>(n.into()) {
+						return false;
+					}
+				}
+				for n in 0 .. *t {
+					if !tail.get::<C>(n.into()) {
+						return false;
+					}
+				}
+				return body.iter().all(|e| *e == T::from(!0));
+			},
+			BitDomain::PartialHead(h, head, body) => {
+				for n in *h .. T::SIZE {
+					if !head.get::<C>(n.into()) {
+						return false;
+					}
+				}
+				return body.iter().all(|e| *e == T::from(!0));
+			},
+			BitDomain::PartialTail(body, tail, t) => {
+				for n in 0 .. *t {
+					if !tail.get::<C>(n.into()) {
+						return false;
+					}
+				}
+				return body.iter().all(|e| *e == T::from(!0));
+			},
+			BitDomain::Spanning(body) => {
+				return body.iter().all(|e| *e == T::from(!0));
+			},
+		}
+		true
+	}
+
+	/// Tests if *any* bit in the slice is set (logical `∨`).
+	///
+	/// # Truth Table
+	///
+	/// ```text
+	/// 0 0 => 0
+	/// 0 1 => 1
+	/// 1 0 => 1
+	/// 1 1 => 1
+	/// ```
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether any bit in the slice domain is set.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x40];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(bv[.. 4].any());
+	/// assert!(!bv[4 ..].any());
+	/// ```
+	pub fn any(&self) -> bool {
+		match self.bitptr().domain() {
+			BitDomain::Empty => return false,
+			BitDomain::Minor(head, elt, tail) => {
+				for n in *head .. *tail {
+					if elt.get::<C>(n.into()) {
+						return true;
+					}
+				}
+			},
+			BitDomain::Major(h, head, body, tail, t) => {
+				for n in *h .. T::SIZE {
+					if head.get::<C>(n.into()) {
+						return true;
+					}
+				}
+				for n in 0 .. *t {
+					if tail.get::<C>(n.into()) {
+						return true;
+					}
+				}
+				return body.iter().any(|e| *e != T::from(0));
+			},
+			BitDomain::PartialHead(h, head, body) => {
+				for n in *h .. T::SIZE {
+					if head.get::<C>(n.into()) {
+						return true;
+					}
+				}
+				return body.iter().any(|e| *e != T::from(0));
+			},
+			BitDomain::PartialTail(body, tail, t) => {
+				for n in 0 .. *t {
+					if tail.get::<C>(n.into()) {
+						return true;
+					}
+				}
+				return body.iter().any(|e| *e != T::from(0));
+			},
+			BitDomain::Spanning(body) => {
+				return body.iter().any(|e| *e != T::from(0));
+			},
+		}
+		false
+	}
+
+	/// Tests if *any* bit in the slice is unset (logical `¬∧`).
+	///
+	/// # Truth Table
+	///
+	/// ```text
+	/// 0 0 => 1
+	/// 0 1 => 1
+	/// 1 0 => 1
+	/// 1 1 => 0
+	/// ```
+	///
+	/// # Parameters
+	///
+	/// - `&self
+	///
+	/// # Returns
+	///
+	/// Whether any bit in the slice domain is unset.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xFD];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(!bv[.. 4].not_all());
+	/// assert!(bv[4 ..].not_all());
+	/// ```
+	pub fn not_all(&self) -> bool {
+		!self.all()
+	}
+
+	/// Tests if *all* bits in the slice are unset (logical `¬∨`).
+	///
+	/// # Truth Table
+	///
+	/// ```text
+	/// 0 0 => 1
+	/// 0 1 => 0
+	/// 1 0 => 0
+	/// 1 1 => 0
+	/// ```
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether all bits in the slice domain are unset.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x40];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(!bv[.. 4].not_any());
+	/// assert!(bv[4 ..].not_any());
+	/// ```
+	pub fn not_any(&self) -> bool {
+		!self.any()
+	}
+
+	/// Tests whether the slice has some, but not all, bits set and some, but
+	/// not all, bits unset.
+	///
+	/// This is `false` if either `all()` or `not_any()` are `true`.
+	///
+	/// # Truth Table
+	///
+	/// ```text
+	/// 0 0 => 0
+	/// 0 1 => 1
+	/// 1 0 => 1
+	/// 1 1 => 0
+	/// ```
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Whether the slice domain has mixed content.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b111_000_10];
+	/// let bv: &BitSlice = store.into();
+	/// assert!(!bv[0 .. 3].some());
+	/// assert!(!bv[3 .. 6].some());
+	/// assert!(bv[6 ..].some());
+	/// ```
+	pub fn some(&self) -> bool {
+		self.any() && self.not_all()
+	}
+
+	/// Counts how many bits are set high.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of high bits in the slice domain.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xFD, 0x25];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.count_ones(), 10);
+	/// ```
+	pub fn count_ones(&self) -> usize {
+		match self.bitptr().domain() {
+			BitDomain::Empty => 0,
+			BitDomain::Minor(head, elt, tail) => {
+				(*head .. *tail)
+					.map(|n| elt.get::<C>(n.into()))
+					.filter(|b| *b)
+					.count()
+			},
+			BitDomain::Major(h, head, body, tail, t) => {
+				(*h .. T::SIZE)
+					.map(|n| head.get::<C>(n.into())).filter(|b| *b).count() +
+				body.iter().map(T::count_ones).sum::<usize>() +
+				(0 .. *t)
+					.map(|n| tail.get::<C>(n.into())).filter(|b| *b).count()
+			},
+			BitDomain::PartialHead(h, head, body) => {
+				(*h .. T::SIZE)
+					.map(|n| head.get::<C>(n.into())).filter(|b| *b).count() +
+				body.iter().map(T::count_ones).sum::<usize>()
+			},
+			BitDomain::PartialTail(body, tail, t) => {
+				body.iter().map(T::count_ones).sum::<usize>() +
+				(0 .. *t)
+					.map(|n| tail.get::<C>(n.into())).filter(|b| *b).count()
+			},
+			BitDomain::Spanning(body) => {
+				body.iter().map(T::count_ones).sum::<usize>()
+			}
+		}
+	}
+
+	/// Counts how many bits are set low.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The number of low bits in the slice domain.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0xFD, 0x25];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.count_zeros(), 6);
+	/// ```
+	pub fn count_zeros(&self) -> usize {
+		match self.bitptr().domain() {
+			BitDomain::Empty => 0,
+			BitDomain::Minor(head, elt, tail) => {
+				(*head .. *tail)
+					.map(|n| !elt.get::<C>(n.into()))
+					.filter(|b| !*b)
+					.count()
+			},
+			BitDomain::Major(h, head, body, tail, t) => {
+				(*h .. T::SIZE)
+					.map(|n| head.get::<C>(n.into())).filter(|b| !*b).count() +
+				body.iter().map(T::count_zeros).sum::<usize>() +
+				(0 .. *t)
+					.map(|n| tail.get::<C>(n.into())).filter(|b| !*b).count()
+			},
+			BitDomain::PartialHead(h, head, body) => {
+				(*h .. T::SIZE)
+					.map(|n| head.get::<C>(n.into())).filter(|b| !*b).count() +
+				body.iter().map(T::count_zeros).sum::<usize>()
+			},
+			BitDomain::PartialTail(body, tail, t) => {
+				body.iter().map(T::count_zeros).sum::<usize>() +
+				(0 .. *t)
+					.map(|n| tail.get::<C>(n.into())).filter(|b| !*b).count()
+			},
+			BitDomain::Spanning(body) => {
+				body.iter().map(T::count_zeros).sum::<usize>()
+			},
+		}
+	}
+
+	/// Set all bits in the slice to a value.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `value`: The bit value to which all bits in the slice will be set.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0];
+	/// let bv: &mut BitSlice = store.into();
+	/// bv[2 .. 6].set_all(true);
+	/// assert_eq!(bv.as_ref(), &[0b0011_1100]);
+	/// bv[3 .. 5].set_all(false);
+	/// assert_eq!(bv.as_ref(), &[0b0010_0100]);
+	/// bv[.. 1].set_all(true);
+	/// assert_eq!(bv.as_ref(), &[0b1010_0100]);
+	/// ```
+	pub fn set_all(&mut self, value: bool) {
+		match self.bitptr().domain_mut() {
+			BitDomainMut::Empty => {},
+			BitDomainMut::Minor(head, elt, tail) => {
+				for n in *head .. *tail {
+					elt.set::<C>(n.into(), value);
+				}
+			},
+			BitDomainMut::Major(h, head, body, tail, t) => {
+				for n in *h .. T::SIZE {
+					head.set::<C>(n.into(), value);
+				}
+				for elt in body {
+					*elt = T::from(0);
+				}
+				for n in 0 .. *t {
+					tail.set::<C>(n.into(), value);
+				}
+			},
+			BitDomainMut::PartialHead(h, head, body) => {
+				for n in *h .. T::SIZE {
+					head.set::<C>(n.into(), value);
+				}
+				for elt in body {
+					*elt = T::from(0);
+				}
+			},
+			BitDomainMut::PartialTail(body, tail, t) => {
+				for elt in body {
+					*elt = T::from(0);
+				}
+				for n in 0 .. *t {
+					tail.set::<C>(n.into(), value);
+				}
+			},
+			BitDomainMut::Spanning(body) => {
+				for elt in body {
+					*elt = T::from(0);
+				}
+			},
+		}
+	}
+
+	/// Provides mutable traversal of the collection.
+	///
+	/// It is impossible to implement `IndexMut` on `BitSlice`, because bits do
+	/// not have addresses, so there can be no `&mut u1`. This method allows the
+	/// client to receive an enumerated bit, and provide a new bit to set at
+	/// each index.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `func`: A function which receives a `(usize, bool)` pair of index and
+	///   value, and returns a bool. It receives the bit at each position, and
+	///   the return value is written back at that position.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	/// ```
+	pub fn for_each<F>(&mut self, func: F)
+	where F: Fn(usize, bool) -> bool {
+		for idx in 0 .. self.len() {
+			let tmp = self[idx];
+			self.set(idx, func(idx, tmp));
+		}
+	}
+
+	/// Accesses the backing storage of the `BitSlice` as a slice of its
+	/// elements.
+	///
+	/// This is different from [`.body()`] in that it always includes the head
+	/// and tail elements, even if they are partial.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// A slice of all the elements that the `BitSlice` uses for storage.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0000_0001, 0b0100_0000];
+	/// let bs: &BitSlice = store.into();
+	///
+	/// let mut accum = 0;
+	/// for elt in bs.as_slice() {
+	///   accum += elt.count_ones();
+	/// }
+	/// assert_eq!(accum, 2);
+	/// ```
+	///
+	/// [`.body()`]: #fn.body
+	pub fn as_slice(&self) -> &[T] {
+		//  Get the `BitPtr` structure.
+		let bp = self.bitptr();
+		//  Get the pointer and element counts from it.
+		let (ptr, len) = (bp.pointer(), bp.elements());
+		//  Create a slice from them.
+		unsafe { slice::from_raw_parts(ptr, len) }
+	}
+
+	/// Accesses the underlying store.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b0000_0001, 0b0100_0000];
+	/// let bs: &mut BitSlice = store.into();
+	/// for elt in bs.as_mut_slice() {
+	///   *elt += 2;
+	/// }
+	/// assert_eq!(&[3, 66], bs.as_slice());
+	/// ```
+	pub fn as_mut_slice(&mut self) -> &mut [T] {
+		//  Get the `BitPtr` structure.
+		let bp = self.bitptr();
+		//  Get the pointer and element counts from it.
+		let (ptr, len) = (bp.pointer() as *mut T, bp.elements());
+		//  Create a slice from them.
+		unsafe { slice::from_raw_parts_mut(ptr, len) }
+	}
+
+	/// Gets an immutable reference to the first element in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Mutable reference to the first element, if and only if it is fully live.
+	pub fn head(&self) -> Option<&T> {
+		//  Transmute into the correct lifetime.
+		unsafe { mem::transmute(self.bitptr().head_elt()) }
+	}
+
+	/// Gets a mutable reference to the first element in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// Reference to the first element, if and only if it is fully live.
+	pub fn head_mut(&mut self) -> Option<&mut T> {
+		unsafe { mem::transmute(self.bitptr().head_elt()) }
+	}
+
+	/// Gets an immutable reference to the fully-populated elements in the
+	/// slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An immutable slice of all the full elements in the slice. This may be
+	/// empty, if the slice has zero, one, or two elements, which are not fully
+	/// live.
+	pub fn body(&self) -> &[T] {
+		let bitptr = self.bitptr();
+		let body = bitptr.body_elts();
+		unsafe { slice::from_raw_parts(body.as_ptr(), body.len()) }
+	}
+
+	/// Gets a mutable reference to the fully-populated elements in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// A mutable slice of all the full elements in the slice. This may be
+	/// empty, if the slice has zero, one, or two elements, which are not fully
+	/// live.
+	pub fn body_mut(&mut self) -> &mut [T] {
+		let bitptr = self.bitptr();
+		let body = bitptr.body_elts();
+		unsafe {
+			slice::from_raw_parts_mut(body.as_ptr() as *mut T, body.len())
+		}
+	}
+
+	/// Gets an immutable reference to the last element in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// Reference to the last element, if and only if it is fully live.
+	pub fn tail(&self) -> Option<&T> {
+		//  Transmute into the correct lifetime.
+		unsafe { mem::transmute(self.bitptr().tail_elt()) }
+	}
+
+	/// Gets a mutable reference to the last element in the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// Mutable reference to the last element, if and only if it is fully live.
+	pub fn tail_mut(&mut self) -> Option<&mut T> {
+		unsafe { mem::transmute(self.bitptr().tail_elt()) }
+	}
+
+	/// Changes the cursor type of the slice handle.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An equivalent slice handle with a new cursor type.
+	///
+	/// # Type Parameters
+	///
+	/// - `D: Cursor` The new cursor type to use for the handle.
+	pub fn change_cursor<D>(&self) -> &BitSlice<D, T>
+	where D: Cursor {
+		self.bitptr().into()
+	}
+
+	/// Changes the cursor type of the slice handle.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// An equivalent slice handle with a new cursor type.
+	///
+	/// # Type Parameters
+	///
+	/// - `D: Cursor` The new cursor type to use for the handle.
+	pub fn change_cursor_mut<D>(&mut self) -> &mut BitSlice<D, T>
+	where D: Cursor {
+		self.bitptr().into()
+	}
+
+	/// Accesses the underlying pointer structure.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The [`BitPtr`] structure of the slice handle.
+	///
+	/// [`BitPtr`]: ../pointer/struct.BitPtr.html
+	pub fn bitptr(&self) -> BitPtr<T> {
+		self.into()
+	}
+}
+
+/// Creates an owned `BitVec<C, T>` from a borrowed `BitSlice<C, T>`.
+#[cfg(feature = "alloc")]
+impl<C, T> ToOwned for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Owned = BitVec<C, T>;
+
+	/// Clones a borrowed `BitSlice` into an owned `BitVec`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// # #[cfg(feature = "alloc")] {
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0; 2];
+	/// let src: &BitSlice = store.into();
+	/// let dst = src.to_owned();
+	/// assert_eq!(src, dst);
+	/// # }
+	/// ```
+	fn to_owned(&self) -> Self::Owned {
+		self.into()
+	}
+}
+
+impl<C, T> Eq for BitSlice<C, T>
+where C: Cursor, T: Bits {}
+
+impl<C, T> Ord for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn cmp(&self, rhs: &Self) -> Ordering {
+		self.partial_cmp(rhs)
+			.unwrap_or_else(|| unreachable!("`BitSlice` has a total ordering"))
+	}
+}
+
+/// Tests if two `BitSlice`s are semantically — not bitwise — equal.
+///
+/// It is valid to compare two slices of different endianness or element types.
+///
+/// The equality condition requires that they have the same number of total bits
+/// and that each pair of bits in semantic order are identical.
+impl<A, B, C, D> PartialEq<BitSlice<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	/// Performas a comparison by `==`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `rhs`: Another `BitSlice` against which to compare. This slice can
+	///   have different cursor or storage types.
+	///
+	/// # Returns
+	///
+	/// If the two slices are equal, by comparing the lengths and bit values at
+	/// each semantic index.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let lstore: &[u8] = &[8, 16, 32, 0];
+	/// let rstore: &[u32] = &[0x10080400];
+	/// let lbv: &BitSlice<LittleEndian, u8> = lstore.into();
+	/// let rbv: &BitSlice<BigEndian, u32> = rstore.into();
+	///
+	/// assert_eq!(lbv, rbv);
+	/// ```
+	fn eq(&self, rhs: &BitSlice<C, D>) -> bool {
+		if self.len() != rhs.len() {
+			return false;
+		}
+		self.iter().zip(rhs.iter()).all(|(l, r)| l == r)
+	}
+}
+
+/// Allow comparison against the allocated form.
+#[cfg(feature = "alloc")]
+impl<A, B, C, D> PartialEq<BitVec<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn eq(&self, rhs: &BitVec<C, D>) -> bool {
+		<Self as PartialEq<BitSlice<C, D>>>::eq(self, &*rhs)
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<A, B, C, D> PartialEq<BitVec<C, D>> for &BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn eq(&self, rhs: &BitVec<C, D>) -> bool {
+		<BitSlice<A, B> as PartialEq<BitSlice<C, D>>>::eq(self, &*rhs)
+	}
+}
+
+/// Compares two `BitSlice`s by semantic — not bitwise — ordering.
+///
+/// The comparison sorts by testing each index for one slice to have a set bit
+/// where the other has an unset bit. If the slices are different, the slice
+/// with the set bit sorts greater than the slice with the unset bit.
+///
+/// If one of the slices is exhausted before they differ, the longer slice is
+/// greater.
+impl<A, B, C, D> PartialOrd<BitSlice<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	/// Performs a comparison by `<` or `>`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `rhs`: Another `BitSlice` against which to compare. This slice can
+	///   have different cursor or storage types.
+	///
+	/// # Returns
+	///
+	/// The relative ordering of `self` against `rhs`. `self` is greater if it
+	/// has a `true` bit at an index where `rhs` has a `false`; `self` is lesser
+	/// if it has a `false` bit at an index where `rhs` has a `true`; if the two
+	/// slices do not disagree then they are compared by length.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x45];
+	/// let slice: &BitSlice = store.into();
+	/// let a = &slice[0 .. 3]; // 010
+	/// let b = &slice[0 .. 4]; // 0100
+	/// let c = &slice[0 .. 5]; // 01000
+	/// let d = &slice[4 .. 8]; // 0101
+	///
+	/// assert!(a < b);
+	/// assert!(b < c);
+	/// assert!(c < d);
+	/// ```
+	fn partial_cmp(&self, rhs: &BitSlice<C, D>) -> Option<Ordering> {
+		for (l, r) in self.iter().zip(rhs.iter()) {
+			match (l, r) {
+				(true, false) => return Some(Ordering::Greater),
+				(false, true) => return Some(Ordering::Less),
+				_ => continue,
+			}
+		}
+		self.len().partial_cmp(&rhs.len())
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<A, B, C, D> PartialOrd<BitVec<C, D>> for BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn partial_cmp(&self, rhs: &BitVec<C, D>) -> Option<Ordering> {
+		self.partial_cmp(&**rhs)
+	}
+}
+
+#[cfg(feature = "alloc")]
+impl<A, B, C, D> PartialOrd<BitVec<C, D>> for &BitSlice<A, B>
+where A: Cursor, B: Bits, C: Cursor, D: Bits {
+	fn partial_cmp(&self, rhs: &BitVec<C, D>) -> Option<Ordering> {
+		(*self).partial_cmp(&**rhs)
+	}
+}
+
+/// Provides write access to all elements in the underlying storage, including
+/// the partial head and tail elements if present.
+impl<C, T> AsMut<[T]> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Accesses the underlying store.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// A mutable slice of all storage elements.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0, 128];
+	/// let bv: &mut BitSlice = store.into();
+	/// let bv = &mut bv[1 .. 9];
+	///
+	/// for elt in bv.as_mut() {
+	///   *elt += 2;
+	/// }
+	///
+	/// assert_eq!(&[2, 130], bv.as_ref());
+	/// ```
+	fn as_mut(&mut self) -> &mut [T] {
+		self.as_mut_slice()
+	}
+}
+
+/// Provides read access to all elements in the underlying storage, including
+/// the partial head and tail elements if present.
+impl<C, T> AsRef<[T]> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Accesses the underlying store.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// An immutable slice of all storage elements.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0, 128];
+	/// let bv: &BitSlice = store.into();
+	/// let bv = &bv[1 .. 9];
+	/// assert_eq!(&[0, 128], bv.as_ref());
+	/// ```
+	fn as_ref(&self) -> &[T] {
+		self.as_slice()
+	}
+}
+
+/// Builds a `BitSlice` from a slice of elements. The resulting `BitSlice` will
+/// always completely fill the original slice.
+impl<'a, C, T> From<&'a [T]> for &'a BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Wraps a `&[T: Bits]` in a `&BitSlice<C: Cursor, T>`. The endianness must
+	/// be specified at the call site. The element type cannot be changed.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The elements over which the new `BitSlice` will operate.
+	///
+	/// # Returns
+	///
+	/// A `BitSlice` representing the original element slice.
+	///
+	/// # Panics
+	///
+	/// The source slice must not exceed the maximum number of elements that a
+	/// `BitSlice` can contain. This value is documented in [`BitPtr`].
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let src: &[u8] = &[1, 2, 3];
+	/// let bits: &BitSlice = src.into();
+	/// assert_eq!(bits.len(), 24);
+	/// assert_eq!(bits.as_ref().len(), 3);
+	/// assert!(bits[7]);  // src[0] == 0b0000_0001
+	/// assert!(bits[14]); // src[1] == 0b0000_0010
+	/// assert!(bits[22]); // src[2] == 0b0000_0011
+	/// assert!(bits[23]);
+	/// ```
+	///
+	/// [`BitPtr`]: ../pointer/struct.BitPtr.html
+	fn from(src: &'a [T]) -> Self {
+		BitPtr::new(src.as_ptr(), src.len(), 0, T::SIZE).into()
+	}
+}
+
+/// Builds a mutable `BitSlice` from a slice of mutable elements. The resulting
+/// `BitSlice` will always completely fill the original slice.
+impl<'a, C, T> From<&'a mut [T]> for &'a mut BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Wraps a `&mut [T: Bits]` in a `&mut BitSlice<C: Cursor, T>`. The
+	/// endianness must be specified by the call site. The element type cannot
+	/// be changed.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The elements over which the new `BitSlice` will operate.
+	///
+	/// # Returns
+	///
+	/// A `BitSlice` representing the original element slice.
+	///
+	/// # Panics
+	///
+	/// The source slice must not exceed the maximum number of elements that a
+	/// `BitSlice` can contain. This value is documented in [`BitPtr`].
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let src: &mut [u8] = &mut [1, 2, 3];
+	/// let bits: &mut BitSlice<LittleEndian, _> = src.into();
+	/// //  The first bit is the LSb of the first element.
+	/// assert!(bits[0]);
+	/// bits.set(0, false);
+	/// assert!(!bits[0]);
+	/// assert_eq!(bits.as_ref(), &[0, 2, 3]);
+	/// ```
+	///
+	/// [`BitPtr`]: ../pointer/struct.BitPtr.html
+	fn from(src: &'a mut [T]) -> Self {
+		BitPtr::new(src.as_ptr(), src.len(), 0, T::SIZE).into()
+	}
+}
+
+/// Converts a `BitPtr` representation into a `BitSlice` handle.
+impl<'a, C, T> From<BitPtr<T>> for &'a BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Converts a `BitPtr` representation into a `BitSlice` handle.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The `BitPtr` representation for the slice.
+	///
+	/// # Returns
+	///
+	/// A `BitSlice` handle for the slice domain the `BitPtr` represents.
+	///
+	/// # Examples
+	///
+	/// This example is crate-internal, and cannot be used by clients.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::*;
+	///
+	/// let store: &[u8] = &[1, 2, 3];
+	/// let bp = BitPtr::new(store.as_ptr(), 3, 2, 6);
+	/// let bv: &BitSlice = bp.into();
+	/// assert_eq!(bv.len(), 20);
+	/// assert_eq!(bv.as_ref(), store);
+	/// # }
+	/// ```
+	fn from(src: BitPtr<T>) -> Self { unsafe {
+		let (ptr, len) = src.bare_parts();
+		let store = slice::from_raw_parts(ptr, len);
+		&*(store as *const [()] as *const _)
+	} }
+}
+
+/// Converts a `BitPtr` representation into a `BitSlice` handle.
+impl<C, T> From<BitPtr<T>> for &mut BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Converts a `BitPtr` representation into a `BitSlice` handle.
+	///
+	/// # Parameters
+	///
+	/// - `src`: The `BitPtr` representation for the slice.
+	///
+	/// # Returns
+	///
+	/// A `BitSlice` handle for the slice domain the `BitPtr` represents.
+	///
+	/// # Examples
+	///
+	/// This example is crate-internal, and cannot be used by clients.
+	///
+	/// ```rust
+	/// # #[cfg(feature = "testing")] {
+	/// use bitvec::testing::*;
+	///
+	/// let store: &mut [u8] = &mut [1, 2, 3];
+	/// let bp = BitPtr::new(store.as_ptr(), 3, 2, 6);
+	/// let bv: &mut BitSlice = bp.into();
+	/// assert_eq!(bv.len(), 20);
+	/// assert_eq!(bv.as_ref(), store);
+	/// # }
+	/// ```
+	fn from(src: BitPtr<T>) -> Self { unsafe {
+		let (ptr, len) = src.bare_parts();
+		let store = slice::from_raw_parts_mut(ptr as *mut (), len);
+		&mut *(store as *mut [()] as *mut _)
+	} }
+}
+
+/// Prints the `BitSlice` for debugging.
+///
+/// The output is of the form `BitSlice<C, T> [ELT, *]` where `<C, T>` is the
+/// cursor and element type, with square brackets on each end of the bits and
+/// all the elements of the array printed in binary. The printout is always in
+/// semantic order, and may not reflect the underlying buffer. To see the
+/// underlying buffer, use `.as_ref()`.
+///
+/// The alternate character `{:#?}` prints each element on its own line, rather
+/// than having all elements on the same line.
+impl<C, T> Debug for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Renders the `BitSlice` type header and contents for debug.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// # #[cfg(feature = "alloc")] {
+	/// use bitvec::prelude::*;
+	/// let bits: &BitSlice<LittleEndian, u16> = &bitvec![
+	///   LittleEndian, u16;
+	///   0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1,
+	///   0, 1
+	/// ];
+	/// assert_eq!(
+    ///     "BitSlice<LittleEndian, u16> [0101000011110101, 01]",
+	///     &format!("{:?}", bits)
+	/// );
+	/// # }
+	/// ```
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		f.write_str("BitSlice<")?;
+		f.write_str(C::TYPENAME)?;
+		f.write_str(", ")?;
+		f.write_str(T::TYPENAME)?;
+		f.write_str("> ")?;
+		Display::fmt(self, f)
+	}
+}
+
+/// Prints the `BitSlice` for displaying.
+///
+/// This prints each element in turn, formatted in binary in semantic order (so
+/// the first bit seen is printed first and the last bit seen is printed last).
+/// Each element of storage is separated by a space for ease of reading.
+///
+/// The alternate character `{:#}` prints each element on its own line.
+///
+/// To see the in-memory representation, use `.as_ref()` to get access to the
+/// raw elements and print that slice instead.
+impl<C, T> Display for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Renders the `BitSlice` contents for display.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `f`: The formatter into which `self` is written.
+	///
+	/// # Returns
+	///
+	/// The result of the formatting operation.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// # #[cfg(feature = "alloc")] {
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b01001011, 0b0100_0000];
+	/// let bits: &BitSlice = store.into();
+	/// assert_eq!("[01001011, 01]", &format!("{}", &bits[.. 10]));
+	/// # }
+	/// ```
+	fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+		struct Part<'a>(&'a str);
+		impl<'a> Debug for Part<'a> {
+			fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+				f.write_str(&self.0)
+			}
+		}
+
+		let mut dbg = f.debug_list();
+		if !self.is_empty() {
+			//  Unfortunately, `T::SIZE` cannot be used as the size for the
+			//  array, due to limitations in the type system. As such, set it to
+			//  the maximum used size.
+			//
+			//  This allows the writes to target a static buffer, rather
+			//  than a dynamic string, making the formatter usable in
+			//  `no-std` contexts.
+			let mut w: [u8; 64] = [0; 64];
+			let writer =
+			|l: &mut DebugList, w: &mut [u8; 64], e: &T, from: u8, to: u8| {
+				let (from, to) = (from as usize, to as usize);
+				for (n, byte) in w.iter_mut().enumerate().take(to).skip(from) {
+					*byte = if e.get::<C>((n as u8).into()) { b'1' }
+					else { b'0' };
+				}
+				l.entry(&Part(unsafe {
+					str::from_utf8_unchecked(&w[from .. to])
+				}));
+			};
+			match self.bitptr().domain() {
+				BitDomain::Empty => {},
+				BitDomain::Minor(head, elt, tail) => {
+					writer(&mut dbg, &mut w, elt, *head, *tail)
+				},
+				BitDomain::Major(h, head, body, tail, t) => {
+					writer(&mut dbg, &mut w, head, *h, T::SIZE);
+					for elt in body {
+						writer(&mut dbg, &mut w, elt, 0, T::SIZE);
+					}
+					writer(&mut dbg, &mut w, tail, 0, *t);
+				},
+				BitDomain::PartialHead(h, head, body) => {
+					writer(&mut dbg, &mut w, head, *h, T::SIZE);
+					for elt in body {
+						writer(&mut dbg, &mut w, elt, 0, T::SIZE);
+					}
+				},
+				BitDomain::PartialTail(body, tail, t) => {
+					for elt in body {
+						writer(&mut dbg, &mut w, elt, 0, T::SIZE);
+					}
+					writer(&mut dbg, &mut w, tail, 0, *t);
+				},
+				BitDomain::Spanning(body) => {
+					for elt in body {
+						writer(&mut dbg, &mut w, elt, 0, T::SIZE);
+					}
+				},
+			}
+		}
+		dbg.finish()
+	}
+}
+
+/// Writes the contents of the `BitSlice`, in semantic bit order, into a hasher.
+impl<C, T> Hash for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Writes each bit of the `BitSlice`, as a full `bool`, into the hasher.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `hasher`: The hashing state into which the slice will be written.
+	///
+	/// # Type Parameters
+	///
+	/// - `H: Hasher`: The type of the hashing algorithm which receives the bits
+	///   of `self`.
+	fn hash<H>(&self, hasher: &mut H)
+	where H: Hasher {
+		for bit in self {
+			hasher.write_u8(bit as u8);
+		}
+	}
+}
+
+/// Produces a read-only iterator over all the bits in the `BitSlice`.
+///
+/// This iterator follows the ordering in the `BitSlice` type, and implements
+/// `ExactSizeIterator` as `BitSlice` has a known, fixed, length, and
+/// `DoubleEndedIterator` as it has known ends.
+impl<'a, C, T> IntoIterator for &'a BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = bool;
+	type IntoIter = Iter<'a, C, T>;
+
+	/// Iterates over the slice.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// An iterator over the slice domain.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b1010_1100];
+	/// let bits: &BitSlice = store.into();
+	/// let mut count = 0;
+	/// for bit in bits {
+	///   if bit { count += 1; }
+	/// }
+	/// assert_eq!(count, 4);
+	/// ```
+	fn into_iter(self) -> Self::IntoIter {
+		Iter {
+			inner: self
+		}
+	}
+}
+
+/// Performs unsigned addition in place on a `BitSlice`.
+///
+/// If the addend bitstream is shorter than `self`, the addend is zero-extended
+/// at the left (so that its final bit matches with `self`’s final bit). If the
+/// addend is longer, the excess front length is unused.
+///
+/// Addition proceeds from the right ends of each slice towards the left.
+/// Because this trait is forbidden from returning anything, the final carry-out
+/// bit is discarded.
+///
+/// Note that, unlike `BitVec`, there is no subtraction implementation until I
+/// find a subtraction algorithm that does not require modifying the subtrahend.
+///
+/// Subtraction can be implemented by negating the intended subtrahend yourself
+/// and then using addition, or by using `BitVec`s instead of `BitSlice`s.
+///
+/// # Type Parameters
+///
+/// - `I: IntoIterator<Item=bool, IntoIter: DoubleEndedIterator>`: The bitstream
+///   to add into `self`. It must be finite and double-ended, since addition
+///   operates in reverse.
+impl<C, T, I> AddAssign<I> for BitSlice<C, T>
+where C: Cursor, T: Bits,
+	I: IntoIterator<Item=bool>, I::IntoIter: DoubleEndedIterator {
+	/// Performs unsigned wrapping addition in place.
+	///
+	/// # Examples
+	///
+	/// This example shows addition of a slice wrapping from max to zero.
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b1110_1111, 0b0000_0001];
+	/// let bv: &mut BitSlice = store.into();
+	/// let (nums, one) = bv.split_at_mut(12);
+	/// let (accum, steps) = nums.split_at_mut(4);
+	/// *accum += &*one;
+	/// assert_eq!(accum, &steps[.. 4]);
+	/// *accum += &*one;
+	/// assert_eq!(accum, &steps[4 ..]);
+	/// ```
+	//  Clippy doesn’t like single-letter names (which is accurate) but this is
+	//  pretty standard mathematical notation in EE.
+	#[allow(clippy::many_single_char_names)]
+	fn add_assign(&mut self, addend: I) {
+		use core::iter::repeat;
+		//  zero-extend the addend if it’s shorter than self
+		let mut addend_iter = addend.into_iter().rev().chain(repeat(false));
+		let mut c = false;
+		for place in (0 .. self.len()).rev() {
+			//  See `BitVec::AddAssign`
+			static JUMP: [u8; 8] = [0, 2, 2, 1, 2, 1, 1, 3];
+			let a = self[place];
+			let b = addend_iter.next().unwrap(); // addend is an infinite source
+			let idx = ((c as u8) << 2) | ((a as u8) << 1) | (b as u8);
+			let yz = JUMP[idx as usize];
+			let (y, z) = (yz & 2 != 0, yz & 1 != 0);
+			self.set(place, y);
+			c = z;
+		}
+	}
+}
+
+/// Performs the Boolean `AND` operation against another bitstream and writes
+/// the result into `self`. If the other bitstream ends before `self,`, the
+/// remaining bits of `self` are cleared.
+///
+/// # Type Parameters
+///
+/// - `I: IntoIterator<Item=bool>`: A stream of bits, which may be a `BitSlice`
+///   or some other bit producer as desired.
+impl<C, T, I> BitAndAssign<I> for BitSlice<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	/// `AND`s a bitstream into a slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `rhs`: The bitstream to `AND` into `self`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b0101_0100];
+	/// let other: &    [u8] = &    [0b0011_0000];
+	/// let lhs: &mut BitSlice = store.into();
+	/// let rhs: &    BitSlice = other.into();
+	/// lhs[.. 6] &= &rhs[.. 4];
+	/// assert_eq!(store[0], 0b0001_0000);
+	/// ```
+	fn bitand_assign(&mut self, rhs: I) {
+		use core::iter;
+		rhs.into_iter()
+			.chain(iter::repeat(false))
+			.enumerate()
+			.take(self.len())
+			.for_each(|(idx, bit)| {
+				let val = self[idx] & bit;
+				self.set(idx, val);
+			});
+	}
+}
+
+/// Performs the Boolean `OR` operation against another bitstream and writes the
+/// result into `self`. If the other bitstream ends before `self`, the remaining
+/// bits of `self` are not affected.
+///
+/// # Type Parameters
+///
+/// - `I: IntoIterator<Item=bool>`: A stream of bits, which may be a `BitSlice`
+///   or some other bit producer as desired.
+impl<C, T, I> BitOrAssign<I> for BitSlice<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	/// `OR`s a bitstream into a slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `rhs`: The bitstream to `OR` into `self`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	/// let store: &mut [u8] = &mut [0b0101_0100];
+	/// let other: &    [u8] = &    [0b0011_0000];
+	/// let lhs: &mut BitSlice = store.into();
+	/// let rhs: &    BitSlice = other.into();
+	/// lhs[.. 6] |= &rhs[.. 4];
+	/// assert_eq!(store[0], 0b0111_0100);
+	/// ```
+	fn bitor_assign(&mut self, rhs: I) {
+		for (idx, bit) in rhs.into_iter().enumerate().take(self.len()) {
+			let val = self[idx] | bit;
+			self.set(idx, val);
+		}
+	}
+}
+
+/// Performs the Boolean `XOR` operation against another bitstream and writes
+/// the result into `self`. If the other bitstream ends before `self`, the
+/// remaining bits of `self` are not affected.
+///
+/// # Type Parameters
+///
+/// - `I: IntoIterator<Item=bool>`: A stream of bits, which may be a `BitSlice`
+///   or some other bit producer as desired.
+impl<C, T, I> BitXorAssign<I> for BitSlice<C, T>
+where C: Cursor, T: Bits, I: IntoIterator<Item=bool> {
+	/// `XOR`s a bitstream into a slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `rhs`: The bitstream to `XOR` into `self`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b0101_0100];
+	/// let other: &    [u8] = &    [0b0011_0000];
+	/// let lhs: &mut BitSlice = store.into();
+	/// let rhs: &    BitSlice = other.into();
+	/// lhs[.. 6] ^= &rhs[.. 4];
+	/// assert_eq!(store[0], 0b0110_0100);
+	/// ```
+	fn bitxor_assign(&mut self, rhs: I) {
+		rhs.into_iter()
+			.enumerate()
+			.take(self.len())
+			.for_each(|(idx, bit)| {
+				let val = self[idx] ^ bit;
+				self.set(idx, val);
+			})
+	}
+}
+
+/// Indexes a single bit by semantic count. The index must be less than the
+/// length of the `BitSlice`.
+impl<C, T> Index<usize> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = bool;
+
+	/// Looks up a single bit by semantic index.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	/// - `index`: The semantic index of the bit to look up.
+	///
+	/// # Returns
+	///
+	/// The value of the bit at the requested index.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0b0010_0000];
+	/// let bits: &BitSlice = store.into();
+	/// assert!(bits[2]);
+	/// assert!(!bits[3]);
+	/// ```
+	fn index(&self, index: usize) -> &Self::Output {
+		let len = self.len();
+		assert!(index < len, "Index out of range: {} >= {}", index, len);
+
+		let h = self.bitptr().head();
+		let (elt, bit) = h.offset::<T>(index as isize);
+		if self.as_ref()[elt as usize].get::<C>(bit) { &true } else { &false }
+	}
+}
+
+impl<C, T> Index<Range<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(&self, Range { start, end }: Range<usize>) -> &Self::Output {
+		let len = self.len();
+		assert!(
+			start <= len,
+			"Index {} out of range: {}",
+			start,
+			len,
+		);
+		assert!(end <= len, "Index {} out of range: {}", end, len);
+		assert!(end >= start, "Ranges can only run from low to high");
+		let (data, _, head, _) = self.bitptr().raw_parts();
+		//  Find the number of elements to drop from the front, and the index of
+		//  the new head
+		let (skip, new_head) = head.offset::<T>(start as isize);
+		//  Find the number of elements contained in the new span, and the index
+		//  of the new tail.
+		let (new_elts, new_tail) = new_head.span::<T>(end - start);
+		BitPtr::new(
+			unsafe { data.offset(skip) },
+			new_elts,
+			new_head,
+			new_tail,
+		).into()
+	}
+}
+
+impl<C, T> IndexMut<Range<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(
+		&mut self,
+		Range { start, end }: Range<usize>,
+	) -> &mut Self::Output {
+		//  Get an immutable slice, and then type-hack mutability back in.
+		(&self[start .. end]).bitptr().into()
+	}
+}
+
+impl<C, T> Index<RangeInclusive<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(&self, index: RangeInclusive<usize>) -> &Self::Output {
+		let start = *index.start();
+		//  This *should* be impossible, but that is presently an implementation
+		//  detail of the `BitPtr` representation, and should not be considered
+		//  an axiom for ranged indexing.
+		if let Some(end) = index.end().checked_add(1) {
+			&self[start .. end]
+		}
+		else {
+			&self[start ..]
+		}
+	}
+}
+
+impl<C, T> IndexMut<RangeInclusive<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, index: RangeInclusive<usize>) -> &mut Self::Output {
+		let start = *index.start();
+		//  This *should* be impossible, but that is presently an implementation
+		//  detail of the `BitPtr` representation, and should not be considered
+		//  an axiom for ranged indexing.
+		if let Some(end) = index.end().checked_add(1) {
+			&mut self[start .. end]
+		}
+		else {
+			&mut self[start ..]
+		}
+	}
+}
+
+impl<C, T> Index<RangeFrom<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(&self, RangeFrom { start }: RangeFrom<usize>) -> &Self::Output {
+		&self[start .. self.len()]
+	}
+}
+
+impl<C, T> IndexMut<RangeFrom<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(
+		&mut self,
+		RangeFrom { start }: RangeFrom<usize>,
+	) -> &mut Self::Output {
+		let len = self.len();
+		&mut self[start .. len]
+	}
+}
+
+impl<C, T> Index<RangeFull> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(&self, _: RangeFull) -> &Self::Output {
+		self
+	}
+}
+
+impl<C, T> IndexMut<RangeFull> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(&mut self, _: RangeFull) -> &mut Self::Output {
+		self
+	}
+}
+
+impl<C, T> Index<RangeTo<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(&self, RangeTo { end }: RangeTo<usize>) -> &Self::Output {
+		&self[0 .. end]
+	}
+}
+
+impl<C, T> IndexMut<RangeTo<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(
+		&mut self,
+		RangeTo { end }: RangeTo<usize>,
+	) -> &mut Self::Output {
+		&mut self[0 .. end]
+	}
+}
+
+impl<C, T> Index<RangeToInclusive<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	type Output = Self;
+
+	fn index(
+		&self,
+		RangeToInclusive { end }: RangeToInclusive<usize>,
+	) -> &Self::Output {
+		&self[0 ..= end]
+	}
+}
+
+impl<C, T> IndexMut<RangeToInclusive<usize>> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	fn index_mut(
+		&mut self,
+		RangeToInclusive { end }: RangeToInclusive<usize>,
+	) -> &mut Self::Output {
+		&mut self[0 ..= end]
+	}
+}
+
+/// Performs fixed-width 2’s-complement negation of a `BitSlice`.
+///
+/// Unlike the `!` operator (`Not` trait), the unary `-` operator treats the
+/// `BitSlice` as if it represents a signed 2’s-complement integer of fixed
+/// width. The negation of a number in 2’s complement is defined as its
+/// inversion (using `!`) plus one, and on fixed-width numbers has the following
+/// discontinuities:
+///
+/// - A slice whose bits are all zero is considered to represent the number zero
+///   which negates as itself.
+/// - A slice whose bits are all one is considered to represent the most
+///   negative number, which has no correpsonding positive number, and thus
+///   negates as zero.
+///
+/// This behavior was chosen so that all possible values would have *some*
+/// output, and so that repeated application converges at idempotence. The most
+/// negative input can never be reached by negation, but `--MOST_NEG` converges
+/// at the least unreasonable fallback value, 0.
+///
+/// Because `BitSlice` cannot move, the negation is performed in place.
+impl<'a, C, T> Neg for &'a mut BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	type Output = Self;
+
+	/// Perform 2’s-complement fixed-width negation.
+	///
+	/// Negation is accomplished by inverting the bits and adding one. This has
+	/// one edge case: `1000…`, the most negative number for its width, will
+	/// negate to zero instead of itself. It thas no corresponding positive
+	/// number to which it can negate.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Examples
+	///
+	/// The contortions shown here are a result of this operator applying to a
+	/// mutable reference, and this example balancing access to the original
+	/// `BitVec` for comparison with aquiring a mutable borrow *as a slice* to
+	/// ensure that the `BitSlice` implementation is used, not the `BitVec`.
+	///
+	/// Negate an arbitrary positive number (first bit unset).
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b0110_1010];
+	/// let bv: &mut BitSlice = store.into();
+	/// eprintln!("{:?}", bv.split_at(4));
+	/// let num = &mut bv[.. 4];
+	/// -num;
+	/// eprintln!("{:?}", bv.split_at(4));
+	/// assert_eq!(&bv[.. 4], &bv[4 ..]);
+	/// ```
+	///
+	/// Negate an arbitrary negative number. This example will use the above
+	/// result to demonstrate round-trip correctness.
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0b1010_0110];
+	/// let bv: &mut BitSlice = store.into();
+	/// let num = &mut bv[.. 4];
+	/// -num;
+	/// assert_eq!(&bv[.. 4], &bv[4 ..]);
+	/// ```
+	///
+	/// Negate the most negative number, which will become zero, and show
+	/// convergence at zero.
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [128];
+	/// let bv: &mut BitSlice = store.into();
+	/// let num = &mut bv[..];
+	/// -num;
+	/// assert!(bv.not_any());
+	/// let num = &mut bv[..];
+	/// -num;
+	/// assert!(bv.not_any());
+	/// ```
+	fn neg(self) -> Self::Output {
+		//  negative zero is zero. The invert-and-add will result in zero, but
+		//  this case can be detected quickly.
+		if self.is_empty() || self.not_any() {
+			return self;
+		}
+		//  The most negative number (leading one, all zeroes else) negates to
+		//  zero.
+		if self[0] {
+			//  Testing the whole range, rather than [1 ..], is more likely to
+			//  hit the fast path.
+			self.set(0, false);
+			if self.not_any() {
+				return self;
+			}
+			self.set(0, true);
+		}
+		let _ = Not::not(&mut *self);
+		let one: &[T] = &[T::from(!0)];
+		let one_bs: &BitSlice<C, T> = one.into();
+		AddAssign::add_assign(&mut *self, &one_bs[.. 1]);
+		self
+	}
+}
+
+/// Flips all bits in the slice, in place.
+impl<'a, C, T> Not for &'a mut BitSlice<C, T>
+where C: Cursor, T: 'a + Bits {
+	type Output = Self;
+
+	/// Inverts all bits in the slice.
+	///
+	/// This will not affect bits outside the slice in slice storage elements.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut [0; 2];
+	/// let bv: &mut BitSlice = store.into();
+	/// let bits = &mut bv[2 .. 14];
+	/// let new_bits = !bits;
+	/// //  The `bits` binding is consumed by the `!` operator, and a new reference
+	/// //  is returned.
+	/// // assert_eq!(bits.as_ref(), &[!0, !0]);
+	/// assert_eq!(new_bits.as_ref(), &[0x3F, 0xFC]);
+	/// ```
+	fn not(self) -> Self::Output {
+		match self.bitptr().domain_mut() {
+			BitDomainMut::Empty => {},
+			BitDomainMut::Minor(head, elt, tail) => {
+				for n in *head .. *tail {
+					let tmp = elt.get::<C>(n.into());
+					elt.set::<C>(n.into(), !tmp);
+				}
+			},
+			BitDomainMut::Major(h, head, body, tail, t) => {
+				for n in *h .. T::SIZE {
+					let tmp = head.get::<C>(n.into());
+					head.set::<C>(n.into(), !tmp);
+				}
+				for elt in body {
+					*elt = !*elt;
+				}
+				for n in 0 .. *t {
+					let tmp = tail.get::<C>(n.into());
+					tail.set::<C>(n.into(), !tmp);
+				}
+			},
+			BitDomainMut::PartialHead(h, head, body) => {
+				for n in *h .. T::SIZE {
+					let tmp = head.get::<C>(n.into());
+					head.set::<C>(n.into(), !tmp);
+				}
+				for elt in body {
+					*elt = !*elt;
+				}
+			},
+			BitDomainMut::PartialTail(body, tail, t) => {
+				for elt in body {
+					*elt = !*elt;
+				}
+				for n in 0 .. *t {
+					let tmp = tail.get::<C>(n.into());
+					tail.set::<C>(n.into(), !tmp);
+				}
+			},
+			BitDomainMut::Spanning(body) => {
+				for elt in body {
+					*elt = !*elt;
+				}
+			},
+		}
+		self
+	}
+}
+
+__bitslice_shift!(u8, u16, u32, u64, i8, i16, i32, i64);
+
+/// Shifts all bits in the array to the left — **DOWN AND TOWARDS THE FRONT**.
+///
+/// On primitives, the left-shift operator `<<` moves bits away from the origin
+/// and towards the ceiling. This is because we label the bits in a primitive
+/// with the minimum on the right and the maximum on the left, which is
+/// big-endian bit order. This increases the value of the primitive being
+/// shifted.
+///
+/// **THAT IS NOT HOW `BitSlice` WORKS!**
+///
+/// `BitSlice` defines its layout with the minimum on the left and the maximum
+/// on the right! Thus, left-shifting moves bits towards the **minimum**.
+///
+/// In BigEndian order, the effect in memory will be what you expect the `<<`
+/// operator to do.
+///
+/// **In LittleEndian order, the effect will be equivalent to using `>>` on**
+/// **the primitives in memory!**
+///
+/// # Notes
+///
+/// In order to preserve the effecs in memory that this operator traditionally
+/// expects, the bits that are emptied by this operation are zeroed rather than
+/// left to their old value.
+///
+/// The shift amount is modulated against the array length, so it is not an
+/// error to pass a shift amount greater than the array length.
+///
+/// A shift amount of zero is a no-op, and returns immediately.
+impl<C, T> ShlAssign<usize> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Shifts a slice left, in place.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `shamt`: The shift amount. If this is greater than the length, then
+	///   the slice is zeroed immediately.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut[0x4B, 0xA5];
+	/// let bv: &mut BitSlice = store.into();
+	/// let bits = &mut bv[2 .. 14];
+	/// *bits <<= 3;
+	/// assert_eq!(bits.as_ref(), &[0b01_011_101, 0b001_000_01]);
+	/// ```
+	fn shl_assign(&mut self, shamt: usize) {
+		use core::ops::Shr;
+		if shamt == 0 {
+			return;
+		}
+		let len = self.len();
+		if shamt >= len {
+			self.set_all(false);
+			return;
+		}
+		//  If the shift amount is an even multiple of the element width, use
+		//  `ptr::copy` instead of a bitwise crawl.
+		if shamt & T::MASK as usize == 0 {
+			//  Compute the shift distance measured in elements.
+			let offset = shamt.shr(T::BITS);
+			//  Compute the number of elements that will remain.
+			let rem = self.as_ref().len().saturating_sub(offset);
+			//  Clear the bits after the tail cursor before the move.
+			for n in *self.bitptr().tail() .. T::SIZE {
+				self.as_mut()[len.saturating_sub(1)].set::<C>(n.into(), false);
+			}
+			//  Memory model: suppose we have this slice of sixteen elements,
+			//  that is shifted five elements to the left. We have three
+			//  pointers and two lengths to manage.
+			//  - rem is 11
+			//  - offset is 5
+			//  - head is [0]
+			//  - body is [5; 11]
+			//  - tail is [11]
+			//  [ 0 1 2 3 4 5 6 7 8 9 a b c d e f ]
+			//              ^-------before------^
+			//    ^-------after-------^ 0 0 0 0 0
+			//  Pointer to the front of the slice
+			let head: *mut T = self.as_mut_ptr();
+			//  Pointer to the front of the section that will move and be
+			//  retained
+			let body: *const T = &self.as_ref()[offset];
+			//  Pointer to the back of the slice that will be zero-filled.
+			let tail: *mut T = &mut self.as_mut()[rem];
+			unsafe {
+				ptr::copy(body, head, rem);
+				ptr::write_bytes(tail, 0, offset);
+			}
+			return;
+		}
+		//  Otherwise, crawl.
+		for (to, from) in (shamt .. len).enumerate() {
+			let val = self[from];
+			self.set(to, val);
+		}
+		for bit in (len.saturating_sub(shamt)) .. len {
+			self.set(bit, false);
+		}
+	}
+}
+
+/// Shifts all bits in the array to the right — **UP AND TOWARDS THE BACK**.
+///
+/// On primitives, the right-shift operator `>>` moves bits towards the origin
+/// and away from the ceiling. This is because we label the bits in a primitive
+/// with the minimum on the right and the maximum on the left, which is
+/// big-endian bit order. This decreases the value of the primitive being
+/// shifted.
+///
+/// **THAT IS NOT HOW `BitSlice` WORKS!**
+///
+/// `BitSlice` defines its layout with the minimum on the left and the maximum
+/// on the right! Thus, right-shifting moves bits towards the **maximum**.
+///
+/// In Big-Endian order, the effect in memory will be what you expect the `>>`
+/// operator to do.
+///
+/// **In LittleEndian order, the effect will be equivalent to using `<<` on**
+/// **the primitives in memory!**
+///
+/// # Notes
+///
+/// In order to preserve the effects in memory that this operator traditionally
+/// expects, the bits that are emptied by this operation are zeroed rather than
+/// left to their old value.
+///
+/// The shift amount is modulated against the array length, so it is not an
+/// error to pass a shift amount greater than the array length.
+///
+/// A shift amount of zero is a no-op, and returns immediately.
+impl<C, T> ShrAssign<usize> for BitSlice<C, T>
+where C: Cursor, T: Bits {
+	/// Shifts a slice right, in place.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `shamt`: The shift amount. If this is greater than the length, then
+	///   the slice is zeroed immediately.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &mut [u8] = &mut[0x4B, 0xA5];
+	/// let bv: &mut BitSlice = store.into();
+	/// let bits = &mut bv[2 .. 14];
+	/// *bits >>= 3;
+	/// assert_eq!(bits.as_ref(), &[0b01_000_00_1, 0b011_101_01])
+	/// ```
+	fn shr_assign(&mut self, shamt: usize) {
+		if shamt == 0 {
+			return;
+		}
+		let len = self.len();
+		if shamt >= len {
+			self.set_all(false);
+			return;
+		}
+		//  IF the shift amount is an even multiple of the element width, use
+		//  `ptr::copy` instead of a bitwise crawl.
+		if shamt & T::MASK as usize == 0 {
+			//  Compute the shift amount measured in elements.
+			let offset = shamt >> T::BITS;
+			// Compute the number of elements that will remain.
+			let rem = self.as_ref().len().saturating_sub(offset);
+			//  Clear the bits ahead of the head cursor before the move.
+			for n in 0 .. *self.bitptr().head() {
+				self.as_mut()[0].set::<C>(n.into(), false);
+			}
+			//  Memory model: suppose we have this slice of sixteen elements,
+			//  that is shifted five elements to the right. We have two pointers
+			//  and two lengths to manage.
+			//  - rem is 11
+			//  - offset is 5
+			//  - head is [0; 11]
+			//  - body is [5]
+			//  [ 0 1 2 3 4 5 6 7 8 9 a b c d e f ]
+			//    ^-------before------^
+			//    0 0 0 0 0 ^-------after-------^
+			let head: *mut T = self.as_mut_ptr();
+			let body: *mut T = &mut self.as_mut()[offset];
+			unsafe {
+				ptr::copy(head, body, rem);
+				ptr::write_bytes(head, 0, offset);
+			}
+			return;
+		}
+		//  Otherwise, crawl.
+		for (from, to) in (shamt .. len).enumerate().rev() {
+			let val = self[from];
+			self.set(to, val);
+		}
+		for bit in 0 .. shamt {
+			self.set(bit, false);
+		}
+	}
+}
+
+/// State keeper for chunked iteration over a `BitSlice`.
+///
+/// # Type Parameters
+///
+/// - `C: Cursor`: The bit-order type of the underlying `BitSlice`.
+/// - `T: 'a + Bits`: The storage type of the underlying `BitSlice`.
+///
+/// # Lifetimes
+///
+/// - `'a`: The lifetime of the underlying `BitSlice`.
+#[derive(Clone, Debug)]
+pub struct Chunks<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// The `BitSlice` being iterated.
+	inner: &'a BitSlice<C, T>,
+	/// The width of the chunks.
+	width: usize,
+}
+
+impl<'a, C, T> DoubleEndedIterator for Chunks<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the next chunk from the back of the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the slice, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[1];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks = bv.chunks(5);
+	/// assert_eq!(chunks.next_back(), Some(&bv[5 ..]));
+	/// assert_eq!(chunks.next_back(), Some(&bv[.. 5]));
+	/// assert!(chunks.next_back().is_none());
+	/// ```
+	fn next_back(&mut self) -> Option<Self::Item> {
+		if self.inner.is_empty() {
+			return None;
+		}
+		let len = self.inner.len();
+		let rem = len % self.width;
+		let size = if rem == 0 { self.width } else { rem };
+		let (head, tail) = self.inner.split_at(len - size);
+		self.inner = head;
+		Some(tail)
+	}
+}
+
+/// Mark that the iterator has an exact size.
+impl<'a, C, T> ExactSizeIterator for Chunks<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+/// Mark that the iterator will not resume after halting.
+impl<'a, C, T> FusedIterator for Chunks<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> Iterator for Chunks<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = &'a BitSlice<C, T>;
+
+	/// Advances the iterator by one, returning the first chunk in it (if any).
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The leading chunk in the iterator, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x80];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks = bv.chunks(5);
+	/// assert_eq!(chunks.next(), Some(&bv[.. 5]));
+	/// assert_eq!(chunks.next(), Some(&bv[5 ..]));
+	/// assert!(chunks.next().is_none());
+	/// ```
+	fn next(&mut self) -> Option<Self::Item> {
+		use core::cmp::min;
+		if self.inner.is_empty() {
+			return None;
+		}
+		let size = min(self.inner.len(), self.width);
+		let (head, tail) = self.inner.split_at(size);
+		self.inner = tail;
+		Some(head)
+	}
+
+	/// Hints at the number of chunks remaining in the iterator.
+	///
+	/// Because the exact size is always known, this always produces
+	/// `(len, Some(len))`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `usize`: The minimum chunks remaining.
+	/// - `Option<usize>`: The maximum chunks remaining.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks = bv.chunks(5);
+	/// assert_eq!(chunks.size_hint(), (2, Some(2)));
+	/// chunks.next();
+	/// assert_eq!(chunks.size_hint(), (1, Some(1)));
+	/// chunks.next();
+	/// assert_eq!(chunks.size_hint(), (0, Some(0)));
+	/// ```
+	fn size_hint(&self) -> (usize, Option<usize>) {
+		if self.inner.is_empty() {
+			return (0, Some(0));
+		}
+		let len = self.inner.len();
+		let (n, r) = (len / self.width, len % self.width);
+		let len = n + (r > 0) as usize;
+		(len, Some(len))
+	}
+
+	/// Counts how many chunks are live in the iterator, consuming it.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The number of chunks remaining in the iterator.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.chunks(3).count(), 3);
+	/// ```
+	fn count(self) -> usize {
+		self.len()
+	}
+
+	/// Advances the iterator by `n` chunks, starting from zero.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `n`: The number of chunks to skip, before producing the next bit after
+	///   skips. If this overshoots the iterator’s remaining length, then the
+	///   iterator is marked empty before returning `None`.
+	///
+	/// # Returns
+	///
+	/// If `n` does not overshoot the iterator’s bounds, this produces the `n`th
+	/// bit after advancing the iterator to it, discarding the intermediate
+	/// chunks.
+	///
+	/// If `n` does overshoot the iterator’s bounds, this empties the iterator
+	/// and returns `None`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks = bv.chunks(3);
+	/// assert_eq!(chunks.nth(1), Some(&bv[3 .. 6]));
+	/// assert_eq!(chunks.nth(0), Some(&bv[6 ..]));
+	/// assert!(chunks.nth(0).is_none());
+	/// ```
+	fn nth(&mut self, n: usize) -> Option<Self::Item> {
+		use core::cmp::min;
+		let (start, ovf) = n.overflowing_mul(self.width);
+		let len = self.inner.len();
+		if start >= len || ovf {
+			self.inner = BitSlice::empty();
+			return None;
+		}
+		let end = start.checked_add(self.width)
+			.map(|s| min(s, len))
+			.unwrap_or(len);
+		let out = &self.inner[start .. end];
+		self.inner = &self.inner[end ..];
+		Some(out)
+	}
+
+	/// Consumes the iterator, returning only the final chunk.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the iterator slice, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.chunks(3).last(), Some(&bv[6 ..]));
+	/// ```
+	fn last(mut self) -> Option<Self::Item> {
+		self.next_back()
+	}
+}
+
+/// State keeper for mutable chunked iteration over a `BitSlice`.
+///
+/// # Type Parameters
+///
+/// - `C: Cursor`: The bit-order type of the underlying `BitSlice`.
+/// - `T: 'a + Bits`: The storage type of the underlying `BitSlice`.
+///
+/// # Lifetimes
+///
+/// - `'a`: The lifetime of the underlying `BitSlice`.
+#[derive(Debug)]
+pub struct ChunksMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// The `BitSlice` being iterated.
+	inner: &'a mut BitSlice<C, T>,
+	/// The width of the chunks.
+	width: usize,
+}
+
+impl<'a, C, T> DoubleEndedIterator for ChunksMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the next chunk from the back of the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the slice, if any.
+	fn next_back(&mut self) -> Option<Self::Item> {
+		if self.inner.is_empty() {
+			return None;
+		}
+		let len = self.inner.len();
+		let rem = len % self.width;
+		let size = if rem == 0 { self.width } else { rem };
+		let tmp = mem::replace(&mut self.inner, BitSlice::empty_mut());
+		let (head, tail) = tmp.split_at_mut(len - size);
+		self.inner = head;
+		Some(tail)
+	}
+}
+
+impl<'a, C, T> ExactSizeIterator for ChunksMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> FusedIterator for ChunksMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> Iterator for ChunksMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = &'a mut BitSlice<C, T>;
+
+	/// Advances the iterator by one, returning the first chunk in it (if any).
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The leading chunk in the iterator, if any.
+	fn next(&mut self) -> Option<Self::Item> {
+		use core::cmp::min;
+		if self.inner.is_empty() {
+			return None;
+		}
+		let size = min(self.inner.len(), self.width);
+		let tmp = mem::replace(&mut self.inner, BitSlice::empty_mut());
+		let (head, tail) = tmp.split_at_mut(size);
+		self.inner = tail;
+		Some(head)
+	}
+
+	/// Hints at the number of chunks remaining in the iterator.
+	///
+	/// Because the exact size is always known, this always produces
+	/// `(len, Some(len))`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `usize`: The minimum chunks remaining.
+	/// - `Option<usize>`: The maximum chunks remaining.
+	fn size_hint(&self) -> (usize, Option<usize>) {
+		if self.inner.is_empty() {
+			return (0, Some(0));
+		}
+		let len = self.inner.len();
+		let (n, r) = (len / self.width, len % self.width);
+		let len = n + (r > 0) as usize;
+		(len, Some(len))
+	}
+
+	/// Counts how many chunks are live in the iterator, consuming it.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The number of chunks remaining in the iterator.
+	fn count(self) -> usize {
+		self.len()
+	}
+
+	/// Advances the iterator by `n` chunks, starting from zero.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `n`: The number of chunks to skip, before producing the next bit after
+	///   skips. If this overshoots the iterator’s remaining length, then the
+	///   iterator is marked empty before returning `None`.
+	///
+	/// # Returns
+	///
+	/// If `n` does not overshoot the iterator’s bounds, this produces the `n`th
+	/// bit after advancing the iterator to it, discarding the intermediate
+	/// chunks.
+	///
+	/// If `n` does overshoot the iterator’s bounds, this empties the iterator
+	/// and returns `None`.
+	fn nth(&mut self, n: usize) -> Option<Self::Item> {
+		use core::cmp::min;
+		let (start, ovf) = n.overflowing_mul(self.width);
+		let len = self.inner.len();
+		if start >= len || ovf {
+			self.inner = BitSlice::empty_mut();
+			return None;
+		}
+		let end = start.checked_add(self.width)
+			.map(|s| min(s, len))
+			.unwrap_or(len);
+		let tmp = mem::replace(&mut self.inner, BitSlice::empty_mut());
+		let (head, tail) = tmp.split_at_mut(start);
+		let (_, nth) = head.split_at_mut(end - start);
+		self.inner = tail;
+		Some(nth)
+	}
+
+	/// Consumes the iterator, returning only the final chunk.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the iterator slice, if any.
+	fn last(mut self) -> Option<Self::Item> {
+		self.next_back()
+	}
+}
+
+/// State keeper for exact chunked iteration over a `BitSlice`.
+///
+/// # Type Parameters
+///
+/// - `C: Cursor`: The bit-order type of the underlying `BitSlice`.
+/// - `T: 'a + Bits`: The storage type of the underlying `BitSlice`.
+///
+/// # Lifetimes
+///
+/// - `'a`: The lifetime of the underlying `BitSlice`.
+#[derive(Clone, Debug)]
+pub struct ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// The `BitSlice` being iterated.
+	inner: &'a BitSlice<C, T>,
+	/// The excess of the original `BitSlice`, which is not iterated.
+	extra: &'a BitSlice<C, T>,
+	/// The width of the chunks.
+	width: usize,
+}
+
+impl<'a, C, T> ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the remainder of the original slice, which will not be included
+	/// in the iteration.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The remaining slice that iteration will not include.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bits: &BitSlice = store.into();
+	/// let chunks_exact = bits.chunks_exact(3);
+	/// assert_eq!(chunks_exact.remainder(), &bits[6 ..]);
+	/// ```
+	pub fn remainder(&self) -> &'a BitSlice<C, T> {
+		self.extra
+	}
+}
+
+impl<'a, C, T> DoubleEndedIterator for ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the next chunk from the back of the slice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the slice, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[1];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks_exact = bv.chunks_exact(3);
+	/// assert_eq!(chunks_exact.next_back(), Some(&bv[3 .. 6]));
+	/// assert_eq!(chunks_exact.next_back(), Some(&bv[0 .. 3]));
+	/// assert!(chunks_exact.next_back().is_none());
+	/// ```
+	fn next_back(&mut self) -> Option<Self::Item> {
+		if self.inner.len() < self.width {
+			self.inner = BitSlice::empty();
+			return None;
+		}
+		let (head, tail) = self.inner.split_at(self.inner.len() - self.width);
+		self.inner = head;
+		Some(tail)
+	}
+}
+
+/// Mark that the iterator has an exact size.
+impl<'a, C, T> ExactSizeIterator for ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+/// Mark that the iterator will not resume after halting.
+impl<'a, C, T> FusedIterator for ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> Iterator for ChunksExact<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = &'a BitSlice<C, T>;
+
+	/// Advances the iterator by one, returning the first chunk in it (if any).
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The leading chunk in the iterator, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x80];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks_exact = bv.chunks_exact(3);
+	/// assert_eq!(chunks_exact.next(), Some(&bv[0 .. 3]));
+	/// assert_eq!(chunks_exact.next(), Some(&bv[3 .. 6]));
+	/// assert!(chunks_exact.next().is_none());
+	/// ```
+	fn next(&mut self) -> Option<Self::Item> {
+		if self.inner.len() < self.width {
+			self.inner = BitSlice::empty();
+			return None;
+		}
+		let (head, tail) = self.inner.split_at(self.width);
+		self.inner = tail;
+		Some(head)
+	}
+
+	/// Hints at the number of chunks remaining in the iterator.
+	///
+	/// Because the exact size is always known, this always produces
+	/// `(len, Some(len))`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `usize`: The minimum chunks remaining.
+	/// - `Option<usize>`: The maximum chunks remaining.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks_exact = bv.chunks_exact(3);
+	/// assert_eq!(chunks_exact.size_hint(), (2, Some(2)));
+	/// chunks_exact.next();
+	/// assert_eq!(chunks_exact.size_hint(), (1, Some(1)));
+	/// chunks_exact.next();
+	/// assert_eq!(chunks_exact.size_hint(), (0, Some(0)));
+	/// ```
+	fn size_hint(&self) -> (usize, Option<usize>) {
+		let len = self.inner.len() / self.width;
+		(len, Some(len))
+	}
+
+	/// Counts how many chunks are live in the iterator, consuming it.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The number of chunks remaining in the iterator.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.chunks_exact(3).count(), 2);
+	/// ```
+	fn count(self) -> usize {
+		self.len()
+	}
+
+	/// Advances the iterator by `n` chunks, starting from zero.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	/// - `n`: The number of chunks to skip, before producing the next bit after
+	///   skips. If this overshoots the iterator’s remaining length, then the
+	///   iterator is marked empty before returning `None`.
+	///
+	/// # Returns
+	///
+	/// If `n` does not overshoot the iterator’s bounds, this produces the `n`th
+	/// bit after advancing the iterator to it, discarding the intermediate
+	/// chunks.
+	///
+	/// If `n` does overshoot the iterator’s bounds, this empties the iterator
+	/// and returns `None`.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[2];
+	/// let bv: &BitSlice = store.into();
+	/// let mut chunks_exact = bv.chunks_exact(3);
+	/// assert_eq!(chunks_exact.nth(1), Some(&bv[3 .. 6]));
+	/// assert!(chunks_exact.nth(0).is_none());
+	/// ```
+	fn nth(&mut self, n: usize) -> Option<Self::Item> {
+		let (start, ovf) = n.overflowing_mul(self.width);
+		if start >= self.inner.len() || ovf {
+			self.inner = BitSlice::empty();
+			return None;
+		}
+		let (_, tail) = self.inner.split_at(start);
+		self.inner = tail;
+		self.next()
+	}
+
+	/// Consumes the iterator, returning only the final chunk.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the iterator slice, if any.
+	///
+	/// # Examples
+	///
+	/// ```rust
+	/// use bitvec::prelude::*;
+	///
+	/// let store: &[u8] = &[0x4B];
+	/// let bv: &BitSlice = store.into();
+	/// assert_eq!(bv.chunks_exact(3).last(), Some(&bv[3 .. 6]));
+	/// ```
+	fn last(mut self) -> Option<Self::Item> {
+		self.next_back()
+	}
+}
+
+/// State keeper for mutable exact chunked iteration over a `BitSlice`.
+///
+/// # Type Parameters
+///
+/// - `C: Cursor`: The bit-order type of the underlying `BitSlice`.
+/// - `T: 'a + Bits`: The storage type of the underlying `BitSlice`.
+///
+/// # Lifetimes
+///
+/// - `'a`: The lifetime of the underlying `BitSlice`.
+#[derive(Debug)]
+pub struct ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// The `BitSlice` being iterated.
+	inner: &'a mut BitSlice<C, T>,
+	/// The excess of the original `BitSlice`, which is not iterated.
+	extra: &'a mut BitSlice<C, T>,
+	/// The width of the chunks.
+	width: usize,
+}
+
+impl<'a, C, T> ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the remainder of the original slice, which will not be included
+	/// in the iteration.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// The remaining slice that iteration will not include.
+	pub fn into_remainder(self) -> &'a mut BitSlice<C, T> {
+		self.extra
+	}
+}
+
+impl<'a, C, T> DoubleEndedIterator for ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	/// Produces the next chunk from the back of th eslice.
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The last chunk in the slice, if any.
+	fn next_back(&mut self) -> Option<Self::Item> {
+		unimplemented!()
+	}
+}
+
+impl<'a, C, T> ExactSizeIterator for ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> FusedIterator for ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {}
+
+impl<'a, C, T> Iterator for ChunksExactMut<'a, C, T>
+where C: Cursor, T: 'a + Bits {
+	type Item = &'a mut BitSlice<C, T>;
+
+	/// Advances the iterator by one, returning the first chunk in it (if any).
+	///
+	/// # Parameters
+	///
+	/// - `&mut self`
+	///
+	/// # Returns
+	///
+	/// The leading chunk in the iterator, if any.
+	fn next(&mut self) -> Option<Self::Item> {
+		if self.inner.len() < self.width {
+			self.inner = BitSlice::empty_mut();
+			return None;
+		}
+		let tmp = mem::replace(&mut self.inner, BitSlice::empty_mut());
+		let (head, tail) = tmp.split_at_mut(self.width);
+		self.inner = tail;
+		Some(head)
+	}
+
+	/// Hints at the number of chunks remaining in the iterator.
+	///
+	/// Because the exact size is always known, this always produces
+	/// `(len, Some(len))`.
+	///
+	/// # Parameters
+	///
+	/// - `&self`
+	///
+	/// # Returns
+	///
+	/// - `usize`: The minimum chunks remaining.
+	/// - `Option<usize>`: The maximum chunks remaining.
+	fn size_hint(&self) -> (usize, Option<usize>) {
+		let len = self.inner.len() / self.width;
+		(len, Some(len))
+	}
+
+	/// Counts how many chunks are live in the iterator, consuming it.
+	///
+	/// # Parameters
+	///
+	/// - `self`
+	///
+	/// # Returns
+	///