diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bef531f..457f307 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -33,6 +33,8 @@ jobs: cargo miri setup - name: Test with Miri run: MIRIFLAGS=-Zmiri-strict-provenance cargo miri test + - name: Run tests for serde feature + run: MIRIFLAGS=-Zmiri-strict-provenance cargo miri test --features serde fmt: runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 6615113..3468773 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bit-set" -version = "0.6.0" +version = "0.7.0" authors = ["Alexis Beingessner "] license = "Apache-2.0 OR MIT" description = "A set of bits" @@ -9,6 +9,7 @@ homepage = "https://github.com/contain-rs/bit-set" documentation = "https://docs.rs/bit-set/" keywords = ["data-structures", "bitset"] readme = "README.md" +edition = "2015" [dependencies] serde = { version = "1.0", features = ["derive"], optional = true } @@ -25,4 +26,3 @@ serde_json = "1.0" default = ["std"] std = ["bit-vec/std"] serde = ["dep:serde", "bit-vec/serde"] -bench = [] diff --git a/README.md b/README.md index 118d045..668ab25 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ [crates.io shield]: https://img.shields.io/crates/v/bit-set?label=latest [crates.io link]: https://crates.io/crates/bit-set -[docs.rs badge]: https://docs.rs/bit-set/badge.svg?version=0.6.0 -[docs.rs link]: https://docs.rs/bit-set/0.6.0/bit_set/ +[docs.rs badge]: https://docs.rs/bit-set/badge.svg?version=0.7.0 +[docs.rs link]: https://docs.rs/bit-set/0.7.0/bit_set/ [github ci badge]: https://github.com/contain-rs/linked-hash-map/workflows/Rust/badge.svg?branch=master [rustc 1.0+]: https://img.shields.io/badge/rustc-1.0%2B-blue.svg [Rust 1.0]: https://blog.rust-lang.org/2015/05/15/Rust-1.0.html -[deps.rs status]: https://deps.rs/crate/bit-set/0.6.0/status.svg -[deps.rs link]: https://deps.rs/crate/bit-set/0.6.0 +[deps.rs status]: https://deps.rs/crate/bit-set/0.7.0/status.svg +[deps.rs link]: https://deps.rs/crate/bit-set/0.7.0 [shields.io download count]: https://img.shields.io/crates/d/bit-set.svg ## Usage diff --git a/RELEASES.md b/RELEASES.md index d1b680b..4e24136 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,10 +1,10 @@ -Version 0.7.0 (not yet released) -========================== +Version 0.7.0 (not yet released) (ZERO BREAKING CHANGES) +======================================================== - `serde::Serialize`, `Deserialize` is derived under the `serde` optional feature - `impl Display` is implemented -- `impl Debug` has different output +- `impl Debug` has different output (we do not promise stable `Debug` output) - `fn truncate` is implemented - `fn get_mut` is implemented diff --git a/benches/bench.rs b/benches/bench.rs new file mode 100644 index 0000000..9c1b1b7 --- /dev/null +++ b/benches/bench.rs @@ -0,0 +1,65 @@ +// Copyright 2012-2024 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] + +extern crate bit_set; +extern crate bit_vec; +extern crate rand; +extern crate test; + +use bit_set::BitSet; +use bit_vec::BitVec; +use rand::{rngs::ThreadRng, thread_rng, RngCore}; + +use test::{black_box, Bencher}; + +const BENCH_BITS: usize = 1 << 14; +const BITS: usize = 32; + +fn rng() -> ThreadRng { + thread_rng() +} + +#[bench] +fn bench_bit_vecset_small(b: &mut Bencher) { + let mut r = rng(); + let mut bit_vec = BitSet::new(); + b.iter(|| { + for _ in 0..100 { + bit_vec.insert((r.next_u32() as usize) % BITS); + } + black_box(&bit_vec); + }); +} + +#[bench] +fn bench_bit_vecset_big(b: &mut Bencher) { + let mut r = rng(); + let mut bit_vec = BitSet::new(); + b.iter(|| { + for _ in 0..100 { + bit_vec.insert((r.next_u32() as usize) % BENCH_BITS); + } + black_box(&bit_vec); + }); +} + +#[bench] +fn bench_bit_vecset_iter(b: &mut Bencher) { + let bit_vec = BitSet::from_bit_vec(BitVec::from_fn(BENCH_BITS, |idx| idx % 3 == 0)); + b.iter(|| { + let mut sum = 0; + for idx in &bit_vec { + sum += idx as usize; + } + sum + }) +} diff --git a/src/lib.rs b/src/lib.rs index eeea4b0..c092d9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,19 +48,14 @@ //! let bv = s.into_bit_vec(); //! assert!(bv[3]); //! ``` - +#![doc(html_root_url = "https://docs.rs/bit-set/0.7.0")] #![no_std] -#![cfg_attr(feature = "bench", feature(test))] extern crate bit_vec; + #[cfg(feature = "serde")] extern crate serde; -#[cfg(test)] -extern crate rand; -#[cfg(feature = "bench")] -extern crate test; - #[cfg(any(test, feature = "std"))] extern crate std; @@ -1684,55 +1679,3 @@ mod tests { } */ } - -#[cfg(feature = "bench")] -mod bench { - use super::BitSet; - use bit_vec::BitVec; - use rand::{rngs::ThreadRng, thread_rng, RngCore}; - - use test::{black_box, Bencher}; - - const BENCH_BITS: usize = 1 << 14; - const BITS: usize = 32; - - fn rng() -> ThreadRng { - thread_rng() - } - - #[bench] - fn bench_bit_vecset_small(b: &mut Bencher) { - let mut r = rng(); - let mut bit_vec = BitSet::new(); - b.iter(|| { - for _ in 0..100 { - bit_vec.insert((r.next_u32() as usize) % BITS); - } - black_box(&bit_vec); - }); - } - - #[bench] - fn bench_bit_vecset_big(b: &mut Bencher) { - let mut r = rng(); - let mut bit_vec = BitSet::new(); - b.iter(|| { - for _ in 0..100 { - bit_vec.insert((r.next_u32() as usize) % BENCH_BITS); - } - black_box(&bit_vec); - }); - } - - #[bench] - fn bench_bit_vecset_iter(b: &mut Bencher) { - let bit_vec = BitSet::from_bit_vec(BitVec::from_fn(BENCH_BITS, |idx| idx % 3 == 0)); - b.iter(|| { - let mut sum = 0; - for idx in &bit_vec { - sum += idx as usize; - } - sum - }) - } -}