Skip to content

Commit

Permalink
Implement Clone for IntoIter for SetU64 (fixes #20)
Browse files Browse the repository at this point in the history
This also removes one use of `unsafe`.
  • Loading branch information
droundy committed Sep 8, 2024
1 parent 6d7b524 commit 0d99eb3
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 281 deletions.
11 changes: 4 additions & 7 deletions src/setu64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,8 @@ impl Iterator for Tiny {
fn min(mut self) -> Option<u64> {
self.next()
}
fn max(mut self) -> Option<u64> {
let mut mx = None;
while let Some(x) = self.next() {
mx = Some(x);
}
mx
fn max(self) -> Option<u64> {
self.last()
}
}

Expand Down Expand Up @@ -1223,10 +1219,11 @@ impl SetU64 {

/// Clears the set, returning all elements in an iterator.
#[inline]
pub fn drain<'a>(&'a mut self) -> impl Iterator<Item = u64> + 'a {
pub fn drain<'a>(&mut self) -> impl Iterator<Item = u64> + 'static {
std::mem::replace(self, SetU64::new()).into_iter()
}

#[inline]
fn internal<'a>(&'a self) -> Internal<'a> {
if self.0 as usize == 0 {
Internal::Empty
Expand Down
Loading

0 comments on commit 0d99eb3

Please sign in to comment.