Skip to content

Commit

Permalink
Fix clippy findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Mar 22, 2024
1 parent 8779205 commit 41ec42f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
1 change: 0 additions & 1 deletion croaring/src/bitmap/imp.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
6 changes: 3 additions & 3 deletions croaring/src/bitmap/iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::iter::{FromIterator, IntoIterator};
use std::marker::PhantomData;
use std::mem::MaybeUninit;

Expand Down Expand Up @@ -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<u32> {
self.move_next();
self.current()
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
6 changes: 2 additions & 4 deletions croaring/src/bitmap64/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
5 changes: 3 additions & 2 deletions croaring/src/bitmap64/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> {
self.move_next();
self.current()
Expand Down Expand Up @@ -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()) };
Expand All @@ -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()) };
Expand Down
31 changes: 18 additions & 13 deletions croaring/src/treemap/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion croaring/src/treemap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 41ec42f

Please sign in to comment.