diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fa27d5b..b7eba20 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,8 +18,6 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose - - name: Run tests (gecko-ffi) - run: cargo test --tests --verbose miri: name: "Miri" diff --git a/Cargo.toml b/Cargo.toml index 9741862..03bda18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bit-set" -version = "0.5.3" +version = "0.6.0" authors = ["Alexis Beingessner "] license = "MIT/Apache-2.0" description = "A set of bits" @@ -20,3 +20,4 @@ default-features = false [features] default = ["std"] std = ["bit-vec/std"] +bench = [] diff --git a/README.md b/README.md index 961c75b..118d045 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.5.3 -[docs.rs link]: https://docs.rs/bit-set/0.5.3/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/ [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.5.3/status.svg -[deps.rs link]: https://deps.rs/crate/bit-set/0.5.3 +[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 [shields.io download count]: https://img.shields.io/crates/d/bit-set.svg ## Usage diff --git a/src/lib.rs b/src/lib.rs index 7b6f5c8..d9c15b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,15 +50,15 @@ //! ``` #![no_std] -#![cfg_attr(all(test, feature = "nightly"), feature(test))] +#![cfg_attr(feature = "bench", feature(test))] + extern crate bit_vec; -#[cfg(all(test, feature = "nightly"))] +#[cfg(test)] extern crate rand; -#[cfg(all(test, feature = "nightly"))] +#[cfg(feature = "bench")] extern crate test; -#[cfg(test)] -#[macro_use] +#[cfg(any(test, feature = "std"))] extern crate std; use bit_vec::{BitBlock, BitVec, Blocks}; @@ -87,6 +87,7 @@ fn blocks_for_bits(bits: usize) -> usize { } } +#[allow(clippy::iter_skip_zero)] // Take two BitVec's, and return iterators of their words, where the shorter one // has been padded with 0's fn match_words<'a, 'b, B: BitBlock>( @@ -163,7 +164,7 @@ impl Extend for BitSet { impl PartialOrd for BitSet { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - self.iter().partial_cmp(other) + Some(self.cmp(other)) } } @@ -392,11 +393,12 @@ impl BitSet { /// use bit_set::BitSet; /// /// let mut s = BitSet::new(); - /// s.insert(32183231); - /// s.remove(32183231); + /// s.insert(3231); + /// s.remove(3231); /// /// // Internal storage will probably be bigger than necessary /// println!("old capacity: {}", s.capacity()); + /// assert!(s.capacity() >= 3231); /// /// // Now should be smaller /// s.shrink_to_fit(); @@ -755,9 +757,7 @@ impl BitSet { /// Returns the number of set bits in this set. #[inline] pub fn len(&self) -> usize { - self.bit_vec - .blocks() - .fold(0, |acc, n| acc + n.count_ones() as usize) + self.bit_vec.blocks().fold(0, |acc, n| acc + n.count_ones()) } /// Returns whether there are no bits set in this set @@ -890,7 +890,7 @@ pub struct Difference<'a, B: 'a>(BlockIter, B>); #[derive(Clone)] pub struct SymmetricDifference<'a, B: 'a>(BlockIter, B>); -impl<'a, T, B: BitBlock> Iterator for BlockIter +impl Iterator for BlockIter where T: Iterator, { @@ -913,7 +913,7 @@ where // update block, removing the LSB self.head = self.head & (self.head - B::one()); // return offset + (index of LSB) - Some(self.head_offset + (B::count_ones(k) as usize)) + Some(self.head_offset + (B::count_ones(k))) } #[inline] @@ -1031,6 +1031,7 @@ mod tests { use bit_vec::BitVec; use std::cmp::Ordering::{Equal, Greater, Less}; use std::vec::Vec; + use std::{format, vec}; #[test] fn test_bit_set_show() { @@ -1557,11 +1558,11 @@ mod tests { */ } -#[cfg(all(test, feature = "nightly"))] +#[cfg(feature = "bench")] mod bench { use super::BitSet; use bit_vec::BitVec; - use rand::{thread_rng, Rng, ThreadRng}; + use rand::{rngs::ThreadRng, thread_rng, RngCore}; use test::{black_box, Bencher};