Skip to content

Commit

Permalink
Merge pull request #33 from contain-rs/ver0.6.0
Browse files Browse the repository at this point in the history
Release version 0.6.0
  • Loading branch information
pczarn authored Jun 29, 2024
2 parents 398ec3b + 0e87d77 commit 7244a58
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bit-set"
version = "0.5.3"
version = "0.6.0"
authors = ["Alexis Beingessner <[email protected]>"]
license = "MIT/Apache-2.0"
description = "A set of bits"
Expand All @@ -20,3 +20,4 @@ default-features = false
[features]
default = ["std"]
std = ["bit-vec/std"]
bench = []
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -87,6 +87,7 @@ fn blocks_for_bits<B: BitBlock>(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>(
Expand Down Expand Up @@ -163,7 +164,7 @@ impl<B: BitBlock> Extend<usize> for BitSet<B> {
impl<B: BitBlock> PartialOrd for BitSet<B> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.iter().partial_cmp(other)
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -392,11 +393,12 @@ impl<B: BitBlock> BitSet<B> {
/// 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();
Expand Down Expand Up @@ -755,9 +757,7 @@ impl<B: BitBlock> BitSet<B> {
/// 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
Expand Down Expand Up @@ -890,7 +890,7 @@ pub struct Difference<'a, B: 'a>(BlockIter<TwoBitPositions<'a, B>, B>);
#[derive(Clone)]
pub struct SymmetricDifference<'a, B: 'a>(BlockIter<TwoBitPositions<'a, B>, B>);

impl<'a, T, B: BitBlock> Iterator for BlockIter<T, B>
impl<T, B: BitBlock> Iterator for BlockIter<T, B>
where
T: Iterator<Item = B>,
{
Expand All @@ -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]
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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};

Expand Down

0 comments on commit 7244a58

Please sign in to comment.