diff --git a/croaring/src/bitmap/imp.rs b/croaring/src/bitmap/imp.rs index 4e02f7b..d89d8fa 100644 --- a/croaring/src/bitmap/imp.rs +++ b/croaring/src/bitmap/imp.rs @@ -1,6 +1,5 @@ use crate::Bitset; use ffi::roaring_bitmap_t; -use std::convert::TryInto; use std::ffi::{c_void, CStr}; use std::ops::{Bound, RangeBounds}; use std::{mem, ptr}; diff --git a/croaring/src/bitmap/iter.rs b/croaring/src/bitmap/iter.rs index f9007e6..7925107 100644 --- a/croaring/src/bitmap/iter.rs +++ b/croaring/src/bitmap/iter.rs @@ -1,4 +1,3 @@ -use std::iter::{FromIterator, IntoIterator}; use std::marker::PhantomData; use std::mem::MaybeUninit; @@ -134,6 +133,7 @@ impl<'a> BitmapCursor<'a> { /// assert_eq!(cursor.next(), None); /// ``` #[inline] + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Option { self.move_next(); self.current() @@ -209,7 +209,7 @@ impl<'a> BitmapCursor<'a> { /// bitmap1.add(100); /// ``` #[must_use] - pub fn reset_to_first<'b>(self, bitmap: &'b Bitmap) -> BitmapCursor<'b> { + pub fn reset_to_first(self, bitmap: &Bitmap) -> BitmapCursor<'_> { BitmapCursor::at_first(bitmap) } @@ -230,7 +230,7 @@ impl<'a> BitmapCursor<'a> { /// assert_eq!(cursor.current(), Some(6)); /// ``` #[must_use] - pub fn reset_to_last<'b>(self, bitmap: &'b Bitmap) -> BitmapCursor<'b> { + pub fn reset_to_last(self, bitmap: &Bitmap) -> BitmapCursor<'_> { BitmapCursor::at_last(bitmap) } diff --git a/croaring/src/bitmap64/imp.rs b/croaring/src/bitmap64/imp.rs index 832dd24..10d55ce 100644 --- a/croaring/src/bitmap64/imp.rs +++ b/croaring/src/bitmap64/imp.rs @@ -1040,10 +1040,8 @@ impl Bitmap64 { end, needs_max, } = exclusive_range; - if needs_max { - if self.contains(u64::MAX) { - return true; - } + if needs_max && self.contains(u64::MAX) { + return true; } unsafe { ffi::roaring64_bitmap_intersect_with_range(self.raw.as_ptr(), start, end) } } diff --git a/croaring/src/bitmap64/iter.rs b/croaring/src/bitmap64/iter.rs index 5e49223..7ab39d9 100644 --- a/croaring/src/bitmap64/iter.rs +++ b/croaring/src/bitmap64/iter.rs @@ -178,6 +178,7 @@ impl<'a> Bitmap64Cursor<'a> { /// assert_eq!(cursor.next(), None); /// ``` #[inline] + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Option { self.move_next(); self.current() @@ -253,7 +254,7 @@ impl<'a> Bitmap64Cursor<'a> { /// bitmap1.add(100); /// ``` #[must_use] - pub fn reset_to_first<'b>(self, bitmap: &'b Bitmap64) -> Bitmap64Cursor<'b> { + pub fn reset_to_first(self, bitmap: &Bitmap64) -> Bitmap64Cursor<'_> { // Don't drop `self` and free the iterator let this = ManuallyDrop::new(self); unsafe { ffi::roaring64_iterator_reinit(bitmap.raw.as_ptr(), this.raw.as_ptr()) }; @@ -277,7 +278,7 @@ impl<'a> Bitmap64Cursor<'a> { /// assert_eq!(cursor.current(), Some(6)); /// ``` #[must_use] - pub fn reset_to_last<'b>(self, bitmap: &'b Bitmap64) -> Bitmap64Cursor<'b> { + pub fn reset_to_last(self, bitmap: &Bitmap64) -> Bitmap64Cursor<'_> { // Don't drop `self` and free the iterator let this = ManuallyDrop::new(self); unsafe { ffi::roaring64_iterator_reinit_last(bitmap.raw.as_ptr(), this.raw.as_ptr()) }; diff --git a/croaring/src/treemap/imp.rs b/croaring/src/treemap/imp.rs index c78f3e9..66872ab 100644 --- a/croaring/src/treemap/imp.rs +++ b/croaring/src/treemap/imp.rs @@ -7,6 +7,7 @@ use std::collections::btree_map::Entry; use std::collections::BTreeMap; use std::ops::{Bound, RangeBounds}; use std::{io, u64}; +use std::cmp::Ordering; impl Treemap { /// Creates an empty `Treemap`. @@ -1220,19 +1221,23 @@ where loop { let (key, bitmap) = match (lhs_next, rhs_next) { (Some((&lhs_key, lhs_bitmap)), Some((&rhs_key, rhs_bitmap))) => { - if lhs_key == rhs_key { - let bitmap = f(BinopArgs::Both(lhs_bitmap, rhs_bitmap)); - lhs_next = lhs_iter.next(); - rhs_next = rhs_iter.next(); - (lhs_key, bitmap) - } else if lhs_key < rhs_key { - let bitmap = f(BinopArgs::Lhs(lhs_bitmap)); - lhs_next = lhs_iter.next(); - (lhs_key, bitmap) - } else { - let bitmap = f(BinopArgs::Rhs(rhs_bitmap)); - rhs_next = rhs_iter.next(); - (rhs_key, bitmap) + match lhs_key.cmp(&rhs_key) { + Ordering::Equal => { + let bitmap = f(BinopArgs::Both(lhs_bitmap, rhs_bitmap)); + lhs_next = lhs_iter.next(); + rhs_next = rhs_iter.next(); + (lhs_key, bitmap) + } + Ordering::Less => { + let bitmap = f(BinopArgs::Lhs(lhs_bitmap)); + lhs_next = lhs_iter.next(); + (lhs_key, bitmap) + } + Ordering::Greater => { + let bitmap = f(BinopArgs::Rhs(rhs_bitmap)); + rhs_next = rhs_iter.next(); + (rhs_key, bitmap) + } } } (Some((&lhs_key, lhs_bitmap)), None) => { diff --git a/croaring/src/treemap/iter.rs b/croaring/src/treemap/iter.rs index f339fc5..7ea7fe3 100644 --- a/croaring/src/treemap/iter.rs +++ b/croaring/src/treemap/iter.rs @@ -2,7 +2,7 @@ use super::util; use crate::bitmap::BitmapIterator; use crate::{Bitmap, Treemap}; use std::collections::btree_map; -use std::iter::{self, FromIterator}; +use std::iter; struct To64Iter<'a> { key: u32,