New:Socket for Asana Is Now Available.Learn more →
Sign In

bitvec

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitvec - cargo Package Compare versions

Comparing version
0.19.2
to
0.19.3
+153
benches/macros.rs
/*! Macro construction benchmarks.
This is taken from [issue #28], which noted that the `bitvec![bit; rep]`
expansion was horribly inefficient.
This benchmark crate should be used for all macro performance recording, and
compare the macros against `vec!`. While `vec!` will always be faster, because
`bitvec!` does more work than `vec!`, they should at least be close.
Original performance was 10,000x slower. Performance after the fix for #28 was
within 20ns.
[issue #28]: https://github.com/myrrlyn/bitvec/issues/28
!*/
#![feature(test)]
extern crate test;
use bitvec::prelude::*;
use test::Bencher;
#[bench]
fn bits_seq_u8(b: &mut Bencher) {
b.iter(|| {
bitarr![LocalBits, u8;
0, 1, 0, 1, 0, 0, 1, 1,
0, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 0, 1, 1, 0, 0,
0, 1, 1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 0, 1, 0, 1, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1, 0, 1,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 1, 1, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 1,
]
});
}
#[bench]
fn bits_seq_u16(b: &mut Bencher) {
b.iter(|| {
bitarr![LocalBits, u16;
0, 1, 0, 1, 0, 0, 1, 1,
0, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 0, 1, 1, 0, 0,
0, 1, 1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 0, 1, 0, 1, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1, 0, 1,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 1, 1, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 1,
]
});
}
#[bench]
fn bits_seq_u32(b: &mut Bencher) {
b.iter(|| {
bitarr![LocalBits, u32;
0, 1, 0, 1, 0, 0, 1, 1,
0, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 0, 1, 1, 0, 0,
0, 1, 1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 0, 1, 0, 1, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1, 0, 1,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 1, 1, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 1,
]
});
}
#[bench]
#[cfg(target_pointer_width = "64")]
fn bits_seq_u64(b: &mut Bencher) {
b.iter(|| {
bitarr![LocalBits, u64;
0, 1, 0, 1, 0, 0, 1, 1,
0, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 0, 1, 1, 0, 0,
0, 1, 1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 0, 1, 0, 1, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 1, 0, 1, 1, 0, 1,
0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 0,
0, 1, 1, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 1,
]
});
}
// The repetition macros run at compile time, so should bench at zero.
#[bench]
fn bits_rep_u8(b: &mut Bencher) {
b.iter(|| bitarr![LocalBits, u8; 0; 120]);
b.iter(|| bitarr![LocalBits, u8; 1; 120]);
}
#[bench]
fn bits_rep_u16(b: &mut Bencher) {
b.iter(|| bitarr![LocalBits, u16; 0; 120]);
b.iter(|| bitarr![LocalBits, u16; 1; 120]);
}
#[bench]
fn bits_rep_u32(b: &mut Bencher) {
b.iter(|| bitarr![LocalBits, u32; 0; 120]);
b.iter(|| bitarr![LocalBits, u32; 1; 120]);
}
#[bench]
#[cfg(target_pointer_width = "64")]
fn bits_rep_u64(b: &mut Bencher) {
b.iter(|| bitarr![LocalBits, u64; 0; 120]);
b.iter(|| bitarr![LocalBits, u64; 1; 120]);
}
#[bench]
fn bitvec_rep(b: &mut Bencher) {
b.iter(|| bitvec![0; 16 * 16 * 9]);
b.iter(|| bitvec![1; 16 * 16 * 9]);
}
#[bench]
fn vec_rep(b: &mut Bencher) {
b.iter(|| vec![0u8; 16 * 16 * 9 / 8]);
b.iter(|| vec![-1i8; 16 * 16 * 9 / 8]);
}
/*! Benchmarks for `BitSlice::copy_from_slice`.
The `copy_from_slice` implementation attempts to detect slice conditions that
allow element-wise `memcpy` behavior, rather than the conservative bit-by-bit
iteration, in the hopes that element load/stores are faster than reading and
writing each bit in an element individually.
At least on the author’s machine, this appears not to be the case. The author
has not inspected the object code emitted by `clone_from_bitslice` and has no
speculation on why this is the case.
!*/
use bitvec::prelude::*;
use criterion::{
criterion_group,
criterion_main,
BenchmarkId,
Criterion,
Throughput,
};
const FACTOR: usize = 1024;
pub fn benchmarks(crit: &mut Criterion) {
let mut group = crit.benchmark_group("accel");
for (kibi, bits) in [1, 2, 4, 8, 16, 32, 64, 128]
.iter()
.copied()
.map(|n| (n, n * FACTOR))
{
group.throughput(Throughput::Elements(bits as u64));
group.bench_with_input(
BenchmarkId::from_parameter(kibi),
&bits,
|b, bits| {
let mut dst: BitVec = BitVec::repeat(false, *bits);
let src: BitVec = BitVec::repeat(true, *bits);
b.iter(|| {
dst[10 .. *bits - 10]
.copy_from_bitslice(&src[10 .. *bits - 10])
});
},
);
}
group.finish();
let mut group = crit.benchmark_group("bitwise");
for (kibi, bits) in [1, 2, 4, 8, 16, 32, 64, 128]
.iter()
.copied()
.map(|n| (n, n * FACTOR))
{
group.throughput(Throughput::Elements(bits as u64));
group.bench_with_input(
BenchmarkId::from_parameter(kibi),
&bits,
|b, bits| {
let mut dst: BitVec = BitVec::repeat(false, *bits);
let src: BitVec = BitVec::repeat(true, *bits);
b.iter(|| dst.clone_from_bitslice(&src));
},
);
}
group.finish();
let mut group = crit.benchmark_group("mismatch");
for (kibi, bits) in [1, 2, 4, 8, 16, 32, 64, 128]
.iter()
.copied()
.map(|n| (n, n * FACTOR))
{
group.throughput(Throughput::Elements(bits as u64));
group.bench_with_input(
BenchmarkId::from_parameter(kibi),
&bits,
|b, bits| {
let mut dst: BitVec<Msb0, u16> = BitVec::repeat(false, *bits);
let src: BitVec<Lsb0, u32> = BitVec::repeat(true, *bits);
b.iter(|| dst.clone_from_bitslice(&src));
},
);
}
group.finish();
}
criterion_group!(benches, benchmarks);
criterion_main!(benches);
#![feature(test)]
extern crate test;
use bitvec::prelude::*;
use test::{
bench::black_box,
Bencher,
};
/* `BitSlice::empty` is not benched, because the compiler const-folds it. It
is not a `const fn`, but it has exactly one function call, which is `const`, and
creates a value object from that function. As such, the compiler can prove that
the return value is a `const` value, and insert the value at all
`BitSlice::empty` call sites. It takes 0ns.
*/
#[bench]
fn element(b: &mut Bencher) {
b.iter(|| BitSlice::<Msb0, u8>::from_element(&!0));
b.iter(|| BitSlice::<Lsb0, u8>::from_element(&!0));
b.iter(|| BitSlice::<Msb0, u16>::from_element(&!0));
b.iter(|| BitSlice::<Lsb0, u16>::from_element(&!0));
b.iter(|| BitSlice::<Msb0, u32>::from_element(&!0));
b.iter(|| BitSlice::<Lsb0, u32>::from_element(&!0));
#[cfg(target_pointer_width = "64")]
{
b.iter(|| BitSlice::<Msb0, u64>::from_element(&!0));
b.iter(|| BitSlice::<Lsb0, u64>::from_element(&!0));
}
}
#[bench]
fn slice(b: &mut Bencher) {
b.iter(|| BitSlice::<Msb0, u8>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Lsb0, u8>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Msb0, u16>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Lsb0, u16>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Msb0, u32>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Lsb0, u32>::from_slice(&[0, 1, !0 - 1, !0][..]));
#[cfg(target_pointer_width = "64")]
{
b.iter(|| BitSlice::<Msb0, u64>::from_slice(&[0, 1, !0 - 1, !0][..]));
b.iter(|| BitSlice::<Lsb0, u64>::from_slice(&[0, 1, !0 - 1, !0][..]));
}
}
#[bench]
fn len(b: &mut Bencher) {
let bsb08 = [0u8; 16].view_bits::<Msb0>();
let bsl08 = [0u8; 16].view_bits::<Lsb0>();
b.iter(|| bsb08.len());
b.iter(|| bsl08.len());
let bsb16 = [0u16; 8].view_bits::<Msb0>();
let bsl16 = [0u16; 8].view_bits::<Lsb0>();
b.iter(|| bsb16.len());
b.iter(|| bsl16.len());
let bsb32 = [0u32; 4].view_bits::<Msb0>();
let bsl32 = [0u32; 4].view_bits::<Lsb0>();
b.iter(|| bsb32.len());
b.iter(|| bsl32.len());
#[cfg(target_pointer_width = "64")]
{
let bsb64 = [0u64; 2].view_bits::<Msb0>();
let bsl64 = [0u64; 2].view_bits::<Lsb0>();
b.iter(|| bsb64.len());
b.iter(|| bsl64.len());
}
}
// This index value is not only "nice", it also ensures that the hard path is
// hit in `BitIdx::offset`.
#[bench]
fn index(b: &mut Bencher) {
let bsb08 = [0u8; 16].view_bits::<Msb0>();
let bsl08 = [0u8; 16].view_bits::<Lsb0>();
b.iter(|| assert!(!black_box(bsb08)[black_box(69)]));
b.iter(|| assert!(!black_box(bsl08)[black_box(69)]));
let bsb16 = [0u16; 8].view_bits::<Msb0>();
let bsl16 = [0u16; 8].view_bits::<Lsb0>();
b.iter(|| assert!(!black_box(bsb16)[black_box(69)]));
b.iter(|| assert!(!black_box(bsl16)[black_box(69)]));
let bsb32 = [0u32; 4].view_bits::<Msb0>();
let bsl32 = [0u32; 4].view_bits::<Lsb0>();
b.iter(|| assert!(!black_box(bsb32)[black_box(69)]));
b.iter(|| assert!(!black_box(bsl32)[black_box(69)]));
#[cfg(target_pointer_width = "64")]
{
let bsb64 = [0u64; 2].view_bits::<Msb0>();
let bsl64 = [0u64; 2].view_bits::<Lsb0>();
b.iter(|| assert!(!black_box(bsb64)[black_box(69)]));
b.iter(|| assert!(!black_box(bsl64)[black_box(69)]));
}
}
/* This routine has more work to do: index, create a reference struct, and drop
it. The compiler *should* be able to properly arrange immediate drops, though.
*/
#[bench]
fn get_mut(b: &mut Bencher) {
let mut src = [0u8; 16];
let bsb08 = src.view_bits_mut::<Msb0>();
b.iter(|| *bsb08.get_mut(69).unwrap() = true);
let mut src = [0u8; 16];
let bsl08 = src.view_bits_mut::<Lsb0>();
b.iter(|| *bsl08.get_mut(69).unwrap() = true);
let mut src = [0u16; 8];
let bsb16 = src.view_bits_mut::<Msb0>();
b.iter(|| *bsb16.get_mut(69).unwrap() = true);
let mut src = [0u16; 8];
let bsl16 = src.view_bits_mut::<Lsb0>();
b.iter(|| *bsl16.get_mut(69).unwrap() = true);
let mut src = [0u32; 4];
let bsb32 = src.view_bits_mut::<Msb0>();
b.iter(|| *bsb32.get_mut(69).unwrap() = true);
let mut src = [0u32; 4];
let bsl32 = src.view_bits_mut::<Lsb0>();
b.iter(|| *bsl32.get_mut(69).unwrap() = true);
#[cfg(target_pointer_width = "64")]
{
let mut src = [0u64; 2];
let bsb64 = src.view_bits_mut::<Msb0>();
b.iter(|| *bsb64.get_mut(69).unwrap() = true);
let mut src = [0u64; 2];
let bsl64 = src.view_bits_mut::<Lsb0>();
b.iter(|| *bsl64.get_mut(69).unwrap() = true);
}
}
+1
-1
{
"git": {
"sha1": "129330cb9d12fbd44aabaa665b04d5378fe84d0e"
"sha1": "6c63769d9186fd4b08436bb3c17d3d3fcfbd438d"
}
}
+595
-25
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "bitvec"
version = "0.19.2"
version = "0.19.3"
dependencies = [
"funty 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"radium 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_test 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wyz 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion",
"funty",
"radium",
"serde",
"serde_json",
"serde_test",
"static_assertions",
"tap",
"wyz",
]
[[package]]
name = "bstr"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]]
name = "byteorder"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "cast"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
dependencies = [
"rustc_version",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "clap"
version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"bitflags",
"textwrap",
"unicode-width",
]
[[package]]
name = "criterion"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8"
dependencies = [
"atty",
"cast",
"clap",
"criterion-plot",
"csv",
"itertools",
"lazy_static",
"num-traits",
"oorandom",
"plotters",
"rayon",
"regex",
"serde",
"serde_cbor",
"serde_derive",
"serde_json",
"tinytemplate",
"walkdir",
]
[[package]]
name = "criterion-plot"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d"
dependencies = [
"cast",
"itertools",
]
[[package]]
name = "crossbeam-channel"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
dependencies = [
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-deque"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-epoch"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"lazy_static",
"maybe-uninit",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "csv"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279"
dependencies = [
"bstr",
"csv-core",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "csv-core"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90"
dependencies = [
"memchr",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "funty"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ba62103ce691c2fd80fbae2213dfdda9ce60804973ac6b6e97de818ea7f52c8"
[[package]]
name = "half"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177"
[[package]]
name = "hermit-abi"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151"
dependencies = [
"libc",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "js-sys"
version = "0.3.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98"
[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
"cfg-if",
]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "memoffset"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
dependencies = [
"autocfg",
]
[[package]]
name = "num-traits"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "oorandom"
version = "11.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c"
[[package]]
name = "plotters"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb"
dependencies = [
"js-sys",
"num-traits",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a333b5f6adeff5a89f2e95dc2ea1ecb5319abbb56212afea6a37f87435338a5"
[[package]]
name = "rayon"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf6960dc9a5b4ee8d3e4c5787b4a112a8818e0290a42ff664ad60692fdf2032"
dependencies = [
"autocfg",
"crossbeam-deque",
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]]
name = "regex"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
dependencies = [
"byteorder",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5"
[[package]]
name = "serde_cbor"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622"
dependencies = [
"half",
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c"
dependencies = [
"itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa",
"ryu",
"serde",
]

@@ -56,4 +486,5 @@

source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "923edec3f1ab4a2f489f384e117dc4f826fd977a9d189b28717cba8474dd5c6b"
dependencies = [
"serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"serde",
]

@@ -65,23 +496,162 @@

source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "tap"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "tinytemplate"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d3dc76004a03cec1c5932bca4cdc2e39aaa798e3f82363dd94f9adf6098c12f"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "walkdir"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
[[package]]
name = "web-sys"
version = "0.3.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wyz"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum funty 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ba62103ce691c2fd80fbae2213dfdda9ce60804973ac6b6e97de818ea7f52c8"
"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
"checksum radium 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5a333b5f6adeff5a89f2e95dc2ea1ecb5319abbb56212afea6a37f87435338a5"
"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
"checksum serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)" = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5"
"checksum serde_json 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)" = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c"
"checksum serde_test 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)" = "923edec3f1ab4a2f489f384e117dc4f826fd977a9d189b28717cba8474dd5c6b"
"checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
"checksum tap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
"checksum wyz 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"

@@ -16,5 +16,5 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "bitvec"
version = "0.19.2"
version = "0.19.3"
authors = ["myrrlyn <self@myrrlyn.dev>"]
include = ["Cargo.toml", "src/**/*.rs"]
include = ["Cargo.toml", "src/**/*.rs", "benches/*.rs"]
description = "A crate for manipulating memory, bit by bit"

@@ -30,2 +30,6 @@ homepage = "https://myrrlyn.net/crates/bitvec"

features = ["atomic", "serde", "std"]
[[bench]]
name = "memcpy"
harness = false
[dependencies.funty]

@@ -49,2 +53,5 @@ version = "1"

default-features = false
[dev-dependencies.criterion]
version = "0.3"
[dev-dependencies.serde]

@@ -51,0 +58,0 @@ version = "1"

@@ -159,3 +159,4 @@ /*! A fixed-size region viewed as individual bits, corresponding to `[bool]`.

/// Constructs a new `BitArray` with zeroed memory.
#[cfg_attr(not(tarpaulin), inline(always))]
#[inline(always)]
#[cfg(not(tarpaulin_include))]
pub fn zeroed() -> Self {

@@ -175,3 +176,4 @@ Self {

/// ```
#[cfg_attr(not(tarpaulin), inline(always))]
#[inline(always)]
#[cfg(not(tarpaulin_include))]
pub fn new(data: V) -> Self {

@@ -194,3 +196,4 @@ Self {

/// ```
#[cfg_attr(not(tarpaulin), inline(always))]
#[inline(always)]
#[cfg(not(tarpaulin_include))]
pub fn unwrap(self) -> V {

@@ -197,0 +200,0 @@ self.data

@@ -1,2 +0,2 @@

//! Operator implementations on `BitArray`
//! Operator implementations on `BitArray`.

@@ -137,3 +137,2 @@ use crate::{

#[cfg(not(tarpaulin_include))]
impl<O, V, Idx> Index<Idx> for BitArray<O, V>

@@ -153,3 +152,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, V, Idx> IndexMut<Idx> for BitArray<O, V>

@@ -156,0 +154,0 @@ where

@@ -1,5 +0,6 @@

//! Trait implementations on `BitArray`
//! Trait implementations on `BitArray`.
use crate::{
array::BitArray,
index::BitIdx,
order::BitOrder,

@@ -90,2 +91,3 @@ slice::BitSlice,

#[cfg(not(tarpaulin_include))]
impl<O, V, Rhs> PartialEq<Rhs> for BitArray<O, V>

@@ -99,3 +101,2 @@ where

#[inline]
#[cfg(not(tarpaulin_include))]
fn eq(&self, other: &Rhs) -> bool {

@@ -169,6 +170,5 @@ self.as_bitslice() == other

#[cfg(not(tarpaulin_include))]
impl<O, O2, T, V> TryFrom<&'_ BitSlice<O2, T>> for BitArray<O, V>
impl<O1, O2, T, V> TryFrom<&'_ BitSlice<O2, T>> for BitArray<O1, V>
where
O: BitOrder,
O1: BitOrder,
O2: BitOrder,

@@ -182,6 +182,6 @@ T: BitStore,

fn try_from(src: &BitSlice<O2, T>) -> Result<Self, Self::Error> {
let mut out = Self::zeroed();
if src.len() != out.len() {
if src.len() != V::const_bits() {
return Self::Error::err();
}
let mut out = Self::zeroed();
out.clone_from_bitslice(src);

@@ -192,3 +192,2 @@ Ok(out)

#[cfg(not(tarpaulin_include))]
impl<'a, O, V> TryFrom<&'a BitSlice<O, V::Store>> for &'a BitArray<O, V>

@@ -204,5 +203,5 @@ where

let bitptr = src.bitptr();
// This pointer cast can only happen if the slice is exactly as long
// as the array, and is aligned to the front of the element.
if src.len() != V::const_bits() || bitptr.head().value() != 0 {
// This pointer cast can only happen if the slice is exactly as long as
// the array, and is aligned to the front of the element.
if src.len() != V::const_bits() || bitptr.head() != BitIdx::ZERO {
return Self::Error::err();

@@ -214,3 +213,2 @@ }

#[cfg(not(tarpaulin_include))]
impl<'a, O, V> TryFrom<&'a mut BitSlice<O, V::Store>> for &'a mut BitArray<O, V>

@@ -228,3 +226,3 @@ where

let bitptr = src.bitptr();
if src.len() != V::const_bits() || bitptr.head().value() != 0 {
if src.len() != V::const_bits() || bitptr.head() != BitIdx::ZERO {
return Self::Error::err();

@@ -260,3 +258,2 @@ }

#[cfg(not(tarpaulin_include))]
impl<O, V> Debug for BitArray<O, V>

@@ -276,2 +273,3 @@ where

)?;
fmt.write_str(" ")?;
}

@@ -387,3 +385,3 @@ Binary::fmt(self, fmt)

impl TryFromBitSliceError {
#[inline]
#[inline(always)]
fn err<T>() -> Result<T, Self> {

@@ -405,1 +403,51 @@ Err(Self)

}
#[cfg(test)]
mod tests {
use crate::prelude::*;
use core::convert::TryInto;
#[test]
fn convert() {
let arr: BitArray<Lsb0, _> = 2u8.into();
assert!(arr.any());
let bits = bits![1; 128];
let arr: BitArray<Msb0, [u16; 8]> = bits.try_into().unwrap();
assert!(arr.all());
let bits = bits![Lsb0, u32; 0; 64];
let arr: &BitArray<Lsb0, [u32; 2]> = bits.try_into().unwrap();
assert!(arr.not_any());
let bits = bits![mut Msb0, u16; 0; 64];
let arr: &mut BitArray<Msb0, [u16; 4]> = bits.try_into().unwrap();
assert!(arr.not_any());
let bits = bits![mut 0; 4];
let bit_arr: Result<&BitArray<LocalBits, usize>, _> =
(&*bits).try_into();
assert!(bit_arr.is_err());
let bit_arr: Result<&mut BitArray<LocalBits, usize>, _> =
bits.try_into();
assert!(bit_arr.is_err());
}
#[test]
#[cfg(feature = "std")]
fn format() {
let render = format!("{:#?}", bitarr![Msb0, u8; 0, 1, 0, 0]);
assert!(
render.starts_with("BitArray<bitvec::order::Msb0, u8> {"),
"{}",
render
);
assert!(
render.ends_with(
" head: 000,\n bits: 8,\n} [\n 0b01000000,\n]"
),
"{}",
render
);
}
}

@@ -164,3 +164,2 @@ /*! A dynamically-allocated, fixed-size, buffer containing a `BitSlice` region.

#[inline]
#[cfg(not(tarpaulin_include))]
pub fn from_bitslice(slice: &BitSlice<O, T>) -> Self {

@@ -167,0 +166,0 @@ slice.to_bitvec().into_boxed_bitslice()

@@ -46,3 +46,4 @@ //! Port of the `Box<[T]>` function API.

/// ```
#[cfg_attr(not(tarpaulin), inline(always))]
#[inline(always)]
#[cfg(not(tarpaulin_include))]
#[deprecated(since = "0.18.0", note = "Prefer `::from_bitslice`")]

@@ -79,3 +80,3 @@ pub fn new(x: &BitSlice<O, T>) -> Self {

/// allocated memory. For this to be safe, the memory must have been
/// allocated in accordance with the [memory layout] used by `Box` .
/// allocated in accordance with the [memory layout] used by `BitBox`.
///

@@ -140,6 +141,7 @@ /// # Original

/// ```rust
/// # use bitvec::prelude::*;
/// use bitvec::prelude::*;
///
/// let b = BitBox::new(bits![Msb0, u32; 0; 32]);
/// let ptr = BitBox::into_raw(b);
/// let b = unsafe { BitBox::<Msb0, _>::from_raw(ptr) };
/// let b = unsafe { BitBox::from_raw(ptr) };
/// ```

@@ -178,4 +180,5 @@ ///

/// ```rust
/// # use bitvec::prelude::*;
/// let b = BitBox::new(bits![LocalBits, u32; 0; 32]);
/// use bitvec::prelude::*;
///
/// let b = bitbox![LocalBits, u32; 0; 32];
/// let static_ref: &'static mut BitSlice<LocalBits, u32> = BitBox::leak(b);

@@ -202,2 +205,4 @@ /// static_ref.set(0, true);

///
/// # API Differences
///
/// Despite taking a `Box<[T]>` receiver, this function is written in an

@@ -214,4 +219,6 @@ /// `impl<T> [T]` block.

///
/// to be written, so this function must be implemented directly on `BitBox`
/// rather than on `BitSlice` with a boxed receiver.
/// to be written, and `BitBox` exists specifically because
/// `Box<BitSlice<>>` cannot be written either, so this function must be
/// implemented directly on `BitBox` rather than on `BitSlice` with a boxed
/// receiver.
///

@@ -230,3 +237,3 @@ /// # Examples

pub fn into_bitvec(self) -> BitVec<O, T> {
let bitptr = self.bitptr();
let mut bitptr = self.bitptr();
let raw = self

@@ -243,5 +250,4 @@ // Disarm the `self` destructor

not alter the address of the heap allocation, and only modifies the
buffer handle. Since the address does not change, the `BitPtr` does not
need to be updated; the only change is that buffer capacity is now
carried locally, rather than frozen in the allocator’s state.
buffer handle. Nevertheless, update the bit-pointer with the address of
the vector as returned by this transformation Just In Case.

@@ -256,2 +262,3 @@ Inspection of the distribution’s implementation shows that the

unsafe {
bitptr.set_pointer(raw.as_ptr() as *const T as *mut T);
BitVec::from_raw_parts(bitptr.to_bitslice_ptr_mut(), raw.capacity())

@@ -258,0 +265,0 @@ }

@@ -1,2 +0,2 @@

//! Trait implementations for `BitBox`
//! Trait implementations for `BitBox`.

@@ -77,3 +77,2 @@ use crate::{

#[cfg(not(tarpaulin_include))]
impl<O, T> Eq for BitBox<O, T>

@@ -266,3 +265,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> Debug for BitBox<O, T>

@@ -374,3 +372,2 @@ where

#[cfg(not(tarpaulin_include))]
unsafe impl<O, T> Send for BitBox<O, T>

@@ -383,3 +380,2 @@ where

#[cfg(not(tarpaulin_include))]
unsafe impl<O, T> Sync for BitBox<O, T>

@@ -392,3 +388,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> Unpin for BitBox<O, T>

@@ -400,1 +395,37 @@ where

}
#[cfg(test)]
mod tests {
use crate::prelude::*;
use core::convert::TryInto;
#[test]
fn convert() {
let boxed: BitBox = bits![1; 64].into();
assert!(boxed.all());
let boxed: BitBox<Lsb0, u32> = bitvec![Lsb0, u32; 0; 64].into();
assert!(boxed.not_any());
let boxed: Box<[u32]> = boxed.into();
assert_eq!(&boxed[..], &[0; 2]);
let _: BitBox<Lsb0, u32> = boxed.try_into().unwrap();
}
#[test]
#[cfg(feature = "std")]
fn format() {
let render = format!("{:#?}", bitbox![Msb0, u8; 0, 1, 0, 0]);
assert!(
render.starts_with("BitBox<bitvec::order::Msb0, u8> {"),
"{}",
render
);
assert!(
render
.ends_with(" head: 000,\n bits: 4,\n} [\n 0b0100,\n]"),
"{}",
render
);
}
}

@@ -323,15 +323,15 @@ /*! Representation of the `BitSlice` region memory model

(retype mut $slice:ident $(,)? ) => {
unsafe { &mut *($slice as *mut BitSlice<O, _> as *mut BitSlice<O, _>) }
};
(retype $slice:ident $(,)? ) => {
unsafe { &*($slice as *const _ as *const _) }
unsafe { &*($slice as *const BitSlice<O, _> as *const BitSlice<O, _>) }
};
(retype mut $slice:ident $(,)? ) => {
unsafe { &mut *($slice as *mut _ as *mut _) }
(split mut $slice:ident, $at:expr $(,)? ) => {
unsafe { $slice.split_at_unchecked_mut($at) }
};
(split $slice:ident, $at:expr $(,)? ) => {
unsafe { $slice.split_at_unchecked($at) }
};
(split mut $slice:ident, $at:expr $(,)? ) => {
unsafe { $slice.split_at_unchecked_mut($at) }
};
}

@@ -342,2 +342,3 @@

#[cfg(not(tarpaulin_include))]
impl<O, T> Clone for BitDomain<'_, O, T>

@@ -349,3 +350,2 @@ where

#[inline(always)]
#[cfg(not(tarpaulin_include))]
fn clone(&self) -> Self {

@@ -605,8 +605,8 @@ *self

(slice mut $base:expr, $elts:expr) => {
unsafe { slice::from_raw_parts_mut($base as *const _ as *mut _, $elts) }
};
(slice $base:expr, $elts:expr) => {
unsafe { slice::from_raw_parts($base as *const _, $elts) }
};
(slice mut $base:expr, $elts:expr) => {
unsafe { slice::from_raw_parts_mut($base as *const _ as *mut _, $elts) }
};
}

@@ -617,2 +617,3 @@

#[cfg(not(tarpaulin_include))]
impl<T> Clone for Domain<'_, T>

@@ -622,3 +623,2 @@ where T: BitStore

#[inline(always)]
#[cfg(not(tarpaulin_include))]
fn clone(&self) -> Self {

@@ -717,3 +717,3 @@ *self

}
) +};
)+ };
}

@@ -720,0 +720,0 @@

@@ -867,4 +867,4 @@ /*! Parallel bitfield access.

#[inline(always)]
#[cfg(target_endian = "little")]
#[cfg(not(tarpaulin_include))]
#[cfg(target_endian = "little")]
unsafe fn resize_inner<T, U>(

@@ -923,3 +923,3 @@ src: &T,

// These tests are purely mathematical, and do not need to run more than once.
#[cfg(all(test, feature = "std", not(tarpaulin)))]
#[cfg(all(test, feature = "std", not(miri), not(tarpaulin)))]
mod permutation_tests;

@@ -1,2 +0,2 @@

/*! Permutation testing
/*! Permutation testing.

@@ -3,0 +3,0 @@ This module runs battery tests on implementations of `BitField` to check that

@@ -10,47 +10,24 @@ //! Tests for the `field` module.

if let Domain::Enclave { head, elem, tail } = bits[3 .. 6].domain() {
let byte = get::<u32, u8>(elem, Lsb0::mask(head, tail), 3);
assert_eq!(byte, 5u8);
}
else {
unreachable!("it does");
}
let (head, elem, tail) = bits[3 .. 6].domain().enclave().unwrap();
let byte = get::<u32, u8>(elem, Lsb0::mask(head, tail), 3);
assert_eq!(byte, 5u8);
if let Domain::Region {
head: None,
body: &[],
tail: Some((elem, tail)),
} = bits[32 .. 48].domain()
{
let short = get::<u32, u16>(elem, Lsb0::mask(None, tail), 0);
assert_eq!(short, 0x4567u16);
}
else {
unreachable!("it does");
}
let (head, body, tail) = bits[32 .. 48].domain().region().unwrap();
assert!(head.is_none());
assert!(body.is_empty());
let (elem, tail) = tail.unwrap();
let short = get::<u32, u16>(elem, Lsb0::mask(None, tail), 0);
assert_eq!(short, 0x4567u16);
if let Domain::Region {
head: Some((head, elem)),
body: &[],
tail: None,
} = bits[48 .. 64].domain()
{
let short = get::<u32, u16>(elem, Lsb0::mask(head, None), 16);
assert_eq!(short, 0x0123u16);
}
else {
unreachable!("it does");
}
let (head, body, tail) = bits[48 .. 64].domain().region().unwrap();
assert!(tail.is_none());
assert!(body.is_empty());
let (head, elem) = head.unwrap();
let short = get::<u32, u16>(elem, Lsb0::mask(head, None), 16);
assert_eq!(short, 0x0123u16);
if let Domain::Region {
head: None,
body,
tail: None,
} = bits[64 .. 96].domain()
{
assert_eq!(body, &[!5]);
}
else {
unreachable!("it does");
}
let (head, body, tail) = bits[64 .. 96].domain().region().unwrap();
assert!(head.is_none());
assert_eq!(body, &[!5]);
assert!(tail.is_none());
}

@@ -63,32 +40,16 @@

if let DomainMut::Enclave { head, elem, tail } = bits[3 .. 6].domain_mut() {
set::<u32, u16>(elem, 13u16, Lsb0::mask(head, tail), 3);
}
else {
unreachable!("it does");
}
let (head, elem, tail) = bits[3 .. 6].domain_mut().enclave().unwrap();
set::<u32, u16>(elem, 13u16, Lsb0::mask(head, tail), 3);
if let DomainMut::Region {
head: None,
body: &mut [],
tail: Some((elem, tail)),
} = bits[32 .. 48].domain_mut()
{
set::<u32, u16>(elem, 0x4567u16, Lsb0::mask(None, tail), 0);
}
else {
unreachable!("it does");
}
let (head, body, tail) = bits[32 .. 48].domain_mut().region().unwrap();
assert!(head.is_none());
assert!(body.is_empty());
let (elem, tail) = tail.unwrap();
set::<u32, u16>(elem, 0x4567u16, Lsb0::mask(None, tail), 0);
if let DomainMut::Region {
head: Some((head, elem)),
body: &mut [],
tail: None,
} = bits[48 .. 64].domain_mut()
{
set::<u32, u16>(elem, 0x0123u16, Lsb0::mask(head, None), 16);
}
else {
unreachable!("it does");
}
let (head, body, tail) = bits[48 .. 64].domain_mut().region().unwrap();
assert!(tail.is_none());
assert!(body.is_empty());
let (head, elem) = head.unwrap();
set::<u32, u16>(elem, 0x0123u16, Lsb0::mask(head, None), 16);

@@ -95,0 +56,0 @@ assert_eq!(data[0], 5 << 3);

@@ -269,2 +269,3 @@ /*! Typed metadata of registers.

#[inline(always)]
#[cfg(not(tarpaulin_include))]
pub fn value(self) -> u8 {

@@ -467,3 +468,4 @@ self.idx

#[cfg(all(feature = "serde", not(tarpaulin_include)))]
#[cfg(feature = "serde")]
#[cfg(not(tarpaulin_include))]
impl<R> Debug for BitIdxErr<R>

@@ -480,3 +482,4 @@ where R: BitRegister

#[cfg(all(feature = "serde", not(tarpaulin_include)))]
#[cfg(feature = "serde")]
#[cfg(not(tarpaulin_include))]
impl<R> Display for BitIdxErr<R>

@@ -496,3 +499,4 @@ where R: BitRegister

#[cfg(all(feature = "serde", feature = "std", not(tarpaulin_include)))]
#[cfg(all(feature = "serde", feature = "std"))]
#[cfg(not(tarpaulin_include))]
impl<R> std::error::Error for BitIdxErr<R> where R: BitRegister

@@ -582,2 +586,3 @@ {

#[inline]
#[cfg(not(tarpaulin_include))]
pub fn value(self) -> u8 {

@@ -584,0 +589,0 @@ self.end

@@ -13,64 +13,2 @@ /*! Internal implementation macros for the public exports.

/** Ensures that the ordering tokens map to a known ordering type path.
Note: non-`const` constructor expressions cannot be used to initialize `static`
bindings. Unfortunately, replacing the `from_slice` calls with literal
construction of the pointer representation, and type-casting it into the correct
type, is *also* unstable, as it requires dereferencing a raw pointer inside a
`static` context.
**/
#[doc(hidden)]
#[macro_export]
macro_rules! __bits_from_slice {
(mut LocalBits, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::LocalBits, _>::from_slice_mut(
&mut $slice,
)
.expect("slice construction exceeded capacity")
.get_unchecked_mut(.. $len)
};
(mut Lsb0, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::Lsb0, _>::from_slice_mut(
&mut $slice,
)
.expect("slice construction exceeded capacity")
.get_unchecked_mut(.. $len)
};
(mut Msb0, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::Msb0, _>::from_slice_mut(
&mut $slice,
)
.expect("slice construction exceeded capacity")
.get_unchecked_mut(.. $len)
};
(mut $order:tt, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$order, _>::from_slice_mut(&mut $slice)
.expect("slice construction exceeded capacity")
.get_unchecked_mut(.. $len)
};
(LocalBits, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::LocalBits, _>::from_slice(
&$slice,
)
.expect("slice construction exceeded capacity")
.get_unchecked(.. $len)
};
(Lsb0, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::Lsb0, _>::from_slice(&$slice)
.expect("slice construction exceeded capacity")
.get_unchecked(.. $len)
};
(Msb0, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$crate::order::Msb0, _>::from_slice(&$slice)
.expect("slice construction exceeded capacity")
.get_unchecked(.. $len)
};
($order:tt, $len:expr, $slice:ident) => {
$crate::slice::BitSlice::<$order, _>::from_slice(&$slice)
.expect("slice construction exceeded capacity")
.get_unchecked(.. $len)
};
}
/** Accumulates a stream of bit expressions into a compacted array of elements.

@@ -244,3 +182,6 @@

Lsb0, $store:ident;
$($a:tt, $b:tt, $c:tt, $d:tt, $e:tt, $f:tt, $g:tt, $h:tt),*
$(
$a:expr, $b:expr, $c:expr, $d:expr,
$e:expr, $f:expr, $g:expr, $h:expr
),*
) => {

@@ -256,3 +197,6 @@ $crate::__ty_from_bytes!(

Msb0, $store:ident;
$($a:tt, $b:tt, $c:tt, $d:tt, $e:tt, $f:tt, $g:tt, $h:tt),*
$(
$a:expr, $b:expr, $c:expr, $d:expr,
$e:expr, $f:expr, $g:expr, $h:expr
),*
) => {

@@ -268,3 +212,6 @@ $crate::__ty_from_bytes!(

LocalBits, $store:ident;
$($a:tt, $b:tt, $c:tt, $d:tt, $e:tt, $f:tt, $g:tt, $h:tt),*
$(
$a:expr, $b:expr, $c:expr, $d:expr,
$e:expr, $f:expr, $g:expr, $h:expr
),*
) => {

@@ -279,39 +226,21 @@ $crate::__ty_from_bytes!(

// Unknown orders are currently unsupported in `macro_rules!`.
(
$order:tt, $store:ident;
$($a:tt, $b:tt, $c:tt, $d:tt, $e:tt, $f:tt, $g:tt, $h:tt),*
$(
$a:expr, $b:expr, $c:expr, $d:expr,
$e:expr, $f:expr, $g:expr, $h:expr
),*
) => {{
/* Note: they can *become* supported, by adding an `ident <-` argument
to the constructor macros that allows construction of runtime non-const
values into a binding with a constant initializer. At present, this is
not done because the `bitarr!` macro relies on lifetime extension of a
borrowed temporary in order to correctly produce a stack object usable
even by the `bits!` borrowing constructor. As of this commit, the
compiler appears to fail to properly extend the lifetime of a terminal
expression of a block, but does extend the lifetime of a free
expression. This prevents using a block to construct temporary
initializers before collecting them into a `BitArray` which can be
lifetime-extended by the caller.
While these two goals (stack-allocation of macro-constructed buffers, vs
accepting any ordering type in the macros) are in contention, stack
allocation is going to win. This will be revisited if the compiler
improves its lifetime-extension behavior.
*/
compile_error!("The ordering argument you provided is unrecognized, and as such cannot be used in const-initializers.");
let mut tmp: $store = 0;
let _tmp_bits = BitSlice::<$order, $store>::from_element_mut(&mut tmp);
let mut _idx = 0;
$(
tmp = tmp
| if $a != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 0) }).value() } else { 0 }
| if $b != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 1) }).value() } else { 0 }
| if $c != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 2) }).value() } else { 0 }
| if $d != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 3) }).value() } else { 0 }
| if $e != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 4) }).value() } else { 0 }
| if $f != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 5) }).value() } else { 0 }
| if $g != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 6) }).value() } else { 0 }
| if $h != 0 { $order::select(unsafe { BitIdx::new_unchecked(_idx + 7) }).value() } else { 0 }
;
_idx += 8;
_tmp_bits.set(_idx, $a != 0); _idx += 1;
_tmp_bits.set(_idx, $b != 0); _idx += 1;
_tmp_bits.set(_idx, $c != 0); _idx += 1;
_tmp_bits.set(_idx, $d != 0); _idx += 1;
_tmp_bits.set(_idx, $e != 0); _idx += 1;
_tmp_bits.set(_idx, $f != 0); _idx += 1;
_tmp_bits.set(_idx, $g != 0); _idx += 1;
_tmp_bits.set(_idx, $h != 0); _idx += 1;
)*

@@ -318,0 +247,0 @@ tmp

@@ -26,2 +26,5 @@ /*! Descriptions of integer types

/// bits on architectures Rust targets.
///
/// Issue #76904 will place this constant on the fundamentals directly, as a
/// `u32`.
const BITS: u8 = mem::size_of::<Self>() as u8 * 8;

@@ -28,0 +31,0 @@ /// The number of bits required to store an index in the range `0 .. BITS`.

@@ -447,14 +447,9 @@ /*! Bitslice pointer encoding

if addr.to_const().is_null() {
if addr.to_const().is_null()
|| (addr.value().trailing_zeros() as usize) < Self::PTR_HEAD_BITS
|| bits > Self::REGION_MAX_BITS
{
return None;
}
if (addr.value().trailing_zeros() as usize) < Self::PTR_HEAD_BITS {
return None;
}
if bits > Self::REGION_MAX_BITS {
return None;
}
let elts = head.span(bits).0;

@@ -812,2 +807,71 @@ let last = addr.to_const().wrapping_add(elts);

/// Produces the distance, in elements and bits, between two bit-pointers.
///
/// # Undefined Behavior
///
/// It is undefined to calculate the distance between pointers that are not
/// part of the same allocation region. This function is defined only when
/// `self` and `other` are produced from the same region.
///
/// # Parameters
///
/// - `self`
/// - `other`: Another `BitPtr<T>`. This function is undefined if it is not
/// produced from the same region as `self`.
///
/// # Returns
///
/// - `.0`: The distance in elements between the first element of `self` and
/// the first element of `other`. Negative if `other` is lower in memory
/// than `self`; positive if `other` is higher.
/// - `.1`: The distance in bits between the first bit of `self` and the
/// first bit of `other`. Negative if `other`’s first bit is lower in its
/// element than is `self`’s first bit; positive if `other`’s first bit is
/// higher in its element than is `self`’s first bit.
///
/// # Truth Tables
///
/// Consider two adjacent bytes in memory. We will define four pairs of
/// bit-pointers of width `1` at various points in this span in order to
/// demonstrate the four possible states of difference.
///
/// ```text
/// [ 0 1 2 3 4 5 6 7 ] [ 8 9 a b c d e f ]
/// 1. A B
/// 2. A B
/// 3. B A
/// 4. B A
/// ```
///
/// 1. The pointer `A` is in the lower element and `B` is in the higher. The
/// first bit of `A` is lower in its element than the first bit of `B` is
/// in its element. `A.ptr_diff(B)` thus produces positive element and
/// bit distances: `(1, 2)`.
/// 2. The pointer `A` is in the lower element and `B` is in the higher. The
/// first bit of `A` is higher in its element than the first bit of `B`
/// is in its element. `A.ptr_diff(B)` thus produces a positive element
/// distance and a negative bit distance: `(1, -3)`.
/// 3. The pointer `A` is in the higher element and `B` is in the lower. The
/// first bit of `A` is lower in its element than the first bit of `B` is
/// in its element. `A.ptr_diff(B)` thus produces a negative element
/// distance and a positive bit distance: `(-1, 4)`.
/// 4. The pointer `A` is in the higher element and `B` is in the lower. The
/// first bit of `A` is higher in its element than the first bit of `B`
/// is in its element. `A.ptr_diff(B)` thus produces negative element and
/// bit distances: `(-1, -5)`.
pub(crate) unsafe fn ptr_diff(self, other: Self) -> (isize, i8) {
let self_ptr = self.pointer();
let other_ptr = other.pointer();
// FIXME(myrrlyn): `core::ptr::offset_from` stabilizes in 1.47.
// let elts = other_ptr.to_const().offset_from(self_ptr.to_const());
let elts = other_ptr
.value()
.wrapping_sub(self_ptr.value())
// Pointers are byte-addressed, so remember to divide the byte
// distance by the element width.
.wrapping_div(core::mem::size_of::<T>()) as isize;
let bits = other.head().value() as i8 - self.head().value() as i8;
(elts, bits)
}
/// Typecasts a raw region pointer into a pointer structure.

@@ -867,2 +931,3 @@ #[inline]

/// the caller.
#[inline(always)]
pub(crate) fn to_bitslice_ref<'a, O>(self) -> &'a BitSlice<O, T>

@@ -885,2 +950,3 @@ where O: BitOrder {

/// the caller.
#[inline(always)]
pub(crate) fn to_bitslice_mut<'a, O>(self) -> &'a mut BitSlice<O, T>

@@ -895,2 +961,3 @@ where O: BitOrder {

/// have any purpose in non-`alloc` programs.
#[inline]
#[cfg(feature = "alloc")]

@@ -932,2 +999,3 @@ pub(crate) fn to_nonnull<O>(self) -> NonNull<BitSlice<O, T>>

/// display their contents if appropriate.
#[inline]
pub(crate) fn render<'a>(

@@ -938,3 +1006,3 @@ &'a self,

ord: Option<&'a str>,
fields: impl IntoIterator<Item = &'a (&'static str, &'a dyn Debug)>,
fields: impl IntoIterator<Item = &'a (&'a str, &'a dyn Debug)>,
) -> fmt::Result

@@ -1015,5 +1083,47 @@ {

#[cfg(not(tarpaulin_include))]
impl<T> Copy for BitPtr<T> where T: BitStore
{
}
#[cfg(test)]
mod tests {
use crate::{
bits,
order::Msb0,
};
#[test]
#[cfg(feature = "alloc")]
fn render() {
let bits = bits![Msb0, u8; 0, 1, 0, 0];
let render = format!("{:?}", bits.bitptr());
assert!(render.starts_with("BitPtr<u8> { addr: 0x"));
assert!(render.ends_with(", head: 000, bits: 4 }"));
let render = format!("{:#?}", bits);
assert!(render.starts_with("BitSlice<bitvec::order::Msb0, u8> {"));
assert!(render.ends_with("} [\n 0b0100,\n]"), "{}", render);
}
#[test]
fn ptr_diff() {
let bits = bits![Msb0, u8; 0; 16];
let a = bits[2 .. 3].bitptr();
let b = bits[12 .. 13].bitptr();
assert_eq!(unsafe { a.ptr_diff(b) }, (1, 2));
let a = bits[5 .. 6].bitptr();
let b = bits[10 .. 11].bitptr();
assert_eq!(unsafe { a.ptr_diff(b) }, (1, -3));
let a = bits[8 .. 9].bitptr();
let b = bits[4 .. 5].bitptr();
assert_eq!(unsafe { a.ptr_diff(b) }, (-1, 4));
let a = bits[14 .. 15].bitptr();
let b = bits[1 .. 2].bitptr();
assert_eq!(unsafe { a.ptr_diff(b) }, (-1, -5));
}
}

@@ -183,3 +183,3 @@ /*! `serde`-powered de/serialization.

}
)* };
)+ };
}

@@ -186,0 +186,0 @@

@@ -23,2 +23,3 @@ //! `BitSlice` iterators

},
iter::FusedIterator,
marker::PhantomData,

@@ -148,6 +149,6 @@ mem,

#[doc(hidden)]
#[cfg(not(tarpaulin_include))]
#[deprecated(
note = "Use `.as_bitslice` on iterators to view the remaining data"
)]
#[cfg(not(tarpaulin_include))]
pub fn as_slice(&self) -> &'a BitSlice<O, T> {

@@ -181,2 +182,3 @@ self.as_bitslice()

#[cfg(not(tarpaulin_include))]
impl<O, T> Clone for Iter<'_, O, T>

@@ -192,2 +194,3 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> AsRef<BitSlice<O, T>> for Iter<'_, O, T>

@@ -198,3 +201,2 @@ where

{
#[cfg(not(tarpaulin_include))]
fn as_ref(&self) -> &BitSlice<O, T> {

@@ -367,5 +369,5 @@ self.as_bitslice()

#[doc(hidden)]
#[cfg(not(tarpaulin_include))]
#[deprecated(note = "Use `.into_bitslice` on mutable iterators to view \
the remaining data")]
#[cfg(not(tarpaulin_include))]
pub fn into_slice(self) -> &'a mut BitSlice<O, T::Alias> {

@@ -559,3 +561,3 @@ self.into_bitslice()

impl<'a, O, T> DoubleEndedIterator for $t<'a, O, T>
impl<'a, O, T> DoubleEndedIterator for $t <'a, O, T>
where

@@ -589,3 +591,3 @@ O: 'a + BitOrder,

impl<O, T> ExactSizeIterator for $t<'_, O, T>
impl<O, T> ExactSizeIterator for $t <'_, O, T>
where

@@ -606,3 +608,4 @@ O: BitOrder,

last.wrapping_sub(base)
.wrapping_shl(T::Mem::INDX as u32)
// Pointers are always byte-stepped, not element-stepped.
.wrapping_shl(<u8 as BitMemory>::INDX as u32)
// Now, add the live bits before `self.tail` in `*last`,

@@ -615,3 +618,3 @@ .wrapping_add(self.tail.value() as usize)

impl<O, T> core::iter::FusedIterator for $t <'_, O, T>
impl<O, T> FusedIterator for $t <'_, O, T>
where

@@ -623,3 +626,3 @@ O: BitOrder,

unsafe impl<O, T> Send for $t<'_, O, T>
unsafe impl<O, T> Send for $t <'_, O, T>
where

@@ -631,3 +634,3 @@ O: BitOrder,

unsafe impl<O, T> Sync for $t<'_, O, T>
unsafe impl<O, T> Sync for $t <'_, O, T>
where

@@ -711,3 +714,3 @@ O: BitOrder,

impl<O, T> core::iter::FusedIterator for $iter <'_, O, T>
impl<O, T> FusedIterator for $iter <'_, O, T>
where

@@ -714,0 +717,0 @@ O: BitOrder,

@@ -158,3 +158,2 @@ /*! Proxy reference for `&mut bool`

#[cfg(not(tarpaulin_include))]
impl<O, T> Debug for BitMut<'_, O, T>

@@ -161,0 +160,0 @@ where

@@ -60,4 +60,3 @@ //! Unit tests for the `slice` module.

fn get_set() {
let mut data = 0u8;
let bits = data.view_bits_mut::<LocalBits>();
let bits = bits![mut LocalBits, u8; 0; 8];

@@ -70,2 +69,7 @@ for n in 0 .. 8 {

assert!(bits.get(9).is_none());
assert!(bits.get_mut(9).is_none());
assert!(bits.get(8 .. 10).is_none());
assert!(bits.get_mut(8 .. 10).is_none());
assert_eq!(bits.first(), Some(&true));

@@ -76,2 +80,7 @@ *bits.first_mut().unwrap() = false;

*crate::slice::BitSliceIndex::index_mut(1usize, bits) = false;
assert_eq!(bits, bits![0, 0, 1, 1, 1, 1, 1, 0]);
assert!(bits.get(100 ..).is_none());
assert!(bits.get(.. 100).is_none());
let (a, b) = (bits![mut Msb0, u8; 0, 1], bits![mut Lsb0, u16; 1, 0]);

@@ -86,2 +95,15 @@ assert_eq!(a, bits![0, 1]);

#[test]
fn memcpy() {
let mut dst = bitarr![0; 500];
let src = bitarr![1; 500];
// Equal heads will fall into the fast path.
dst[10 .. 20].copy_from_bitslice(&src[74 .. 84]);
dst[100 .. 500].copy_from_bitslice(&src[36 .. 436]);
// Unequal heads will trip the slow path.
dst[.. 490].copy_from_bitslice(&src[10 .. 500]);
}
#[test]
fn query() {

@@ -272,1 +294,19 @@ let data = [0x0Fu8, !0, 0xF0, 0, 0x0E];

}
#[test]
#[cfg(feature = "alloc")]
fn repetition() {
let bits = bits![0, 0, 1, 1];
let bv = bits.repeat(2);
assert_eq!(bv, bits![0, 0, 1, 1, 0, 0, 1, 1]);
}
#[test]
fn pointer_offset() {
let data = [0u16; 2];
let bits = data.view_bits::<Msb0>();
let a = &bits[10 .. 11];
let b = &bits[20 .. 21];
assert_eq!(a.offset_from(b), 10);
}

@@ -288,3 +288,2 @@ //! Trait implementations for `BitSlice`

#[cfg(not(tarpaulin_include))]
impl<O, T> Debug for BitSlice<O, T>

@@ -317,4 +316,9 @@ where

/// Renders a `BitSlice` handle as its pointer representation.
#[cfg(not(tarpaulin_include))]
/** Renders a `BitSlice` handle as its pointer representation.
This does not enable `{:p}` in a format string, as there is a blanket `Pointer`
implementation for all references, and unsized types cannot format by
themselves. It is only reachable by forwarding from another format marker, such
as `Debug`.
**/
impl<O, T> Pointer for BitSlice<O, T>

@@ -383,4 +387,4 @@ where

*/
let mut w: [u8; (usize::BITS as usize / $blksz) + 2] =
[b'0'; (usize::BITS as usize / $blksz) + 2];
const W: usize = <usize as BitMemory>::BITS as usize / $blksz;
let mut w: [u8; W + 2] = [b'0'; W + 2];
// Write the prefix symbol into the buffer.

@@ -387,0 +391,0 @@ w[1] = $pfx;

@@ -260,3 +260,3 @@ /*! Memory modeling.

// If these are true for `R: BitRegister`, then they are true for `Cell<R>`.
// If these are true for `R: BitRegister`, then they are true for `Cell<R>`.

@@ -263,0 +263,0 @@ #[doc(hidden)]

@@ -160,2 +160,11 @@ /*! A dynamically-allocated buffer containing a `BitSlice<O, T>` region.

/// A `BitVec` with `len` live bits, all set to `bit`.
///
/// # Examples
///
/// ```rust
/// use bitvec::prelude::*;
///
/// let bv = BitVec::<Msb0, u8>::repeat(true, 20);
/// assert_eq!(bv, bits![1; 20]);
/// ```
#[inline]

@@ -202,6 +211,7 @@ pub fn repeat(bit: bool, len: usize) -> Self {

let mut vec = elts.pipe(Vec::with_capacity).pipe(ManuallyDrop::new);
let vec = elts
.pipe(Vec::with_capacity)
.pipe(ManuallyDrop::new)
.tap_mut(|v| v.extend(source.iter().map(BitStore::load_value)));
vec.extend(source.iter().map(BitStore::load_value));
unsafe {

@@ -631,2 +641,3 @@ bitptr.set_pointer(vec.as_ptr() as *const T);

#[inline]
#[cfg(not(tarpaulin_include))]
pub(crate) fn bitptr(&self) -> BitPtr<T> {

@@ -633,0 +644,0 @@ self.pointer.as_ptr().pipe(BitPtr::from_bitslice_ptr_mut)

@@ -251,5 +251,5 @@ //! `BitVec` iterators

#[doc(hidden)]
#[cfg(not(tarpaulin_include))]
#[deprecated(note = "Use `.as_mut_bitslice()` on iterators to view the \
remaining data.")]
#[cfg(not(tarpaulin_include))]
pub fn as_mut_slice(&mut self) -> &mut BitSlice<O, T> {

@@ -268,3 +268,3 @@ self.as_mut_bitslice()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn next(&mut self) -> Option<Self::Item> {

@@ -274,3 +274,3 @@ self.iter.next().copied()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn size_hint(&self) -> (usize, Option<usize>) {

@@ -280,3 +280,3 @@ self.iter.size_hint()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn count(self) -> usize {

@@ -286,3 +286,3 @@ self.len()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn nth(&mut self, n: usize) -> Option<Self::Item> {

@@ -292,3 +292,3 @@ self.iter.nth(n).copied()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn last(mut self) -> Option<Self::Item> {

@@ -305,3 +305,3 @@ self.next_back()

{
#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn next_back(&mut self) -> Option<Self::Item> {

@@ -311,3 +311,3 @@ self.iter.next_back().copied()

#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {

@@ -324,3 +324,3 @@ self.iter.nth_back(n).copied()

{
#[cfg_attr(not(tarpaulin_include), inline(always))]
#[inline(always)]
fn len(&self) -> usize {

@@ -703,3 +703,2 @@ self.iter.len()

#[cfg(not(tarpaulin_include))]
impl<O, T, I> Iterator for Splice<'_, O, T, I>

@@ -739,2 +738,3 @@ where

#[inline(always)]
#[cfg(not(tarpaulin_include))]
fn size_hint(&self) -> (usize, Option<usize>) {

@@ -745,2 +745,3 @@ self.drain.size_hint()

#[inline(always)]
#[cfg(not(tarpaulin_include))]
fn count(self) -> usize {

@@ -747,0 +748,0 @@ self.drain.len()

@@ -73,2 +73,3 @@ //! Trait implementations for `BitVec`.

#[inline]
#[cfg(not(tarpaulin_include))]
fn clone(&self) -> Self {

@@ -95,3 +96,2 @@ self.as_bitslice().pipe(Self::from_bitslice)

#[cfg(not(tarpaulin_include))]
impl<O, T> Eq for BitVec<O, T>

@@ -294,3 +294,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> Debug for BitVec<O, T>

@@ -359,3 +358,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> Pointer for BitVec<O, T>

@@ -401,3 +399,2 @@ where

#[cfg(not(tarpaulin_include))]
unsafe impl<O, T> Send for BitVec<O, T>

@@ -410,3 +407,2 @@ where

#[cfg(not(tarpaulin_include))]
unsafe impl<O, T> Sync for BitVec<O, T>

@@ -419,3 +415,2 @@ where

#[cfg(not(tarpaulin_include))]
impl<O, T> Unpin for BitVec<O, T>

@@ -422,0 +417,0 @@ where

@@ -74,2 +74,3 @@ /*! View constructors for memory regions.

#[inline(always)]
#[cfg(not(tarpaulin_include))]
#[deprecated(

@@ -102,2 +103,3 @@ since = "0.18.0",

#[inline(always)]
#[cfg(not(tarpaulin_include))]
#[deprecated(

@@ -104,0 +106,0 @@ since = "0.18.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display