Skip to content

Commit

Permalink
Merge pull request #50 from LighghtEeloo/derive_clone
Browse files Browse the repository at this point in the history
Use derive macro for `impl Clone`
  • Loading branch information
pczarn authored Nov 29, 2024
2 parents 0d8d832 + b9e1307 commit 11a0bd2
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ macro_rules! double_ended_iterator {
}

/// An iterator over the key-value pairs of a map.
#[derive(Clone)]
pub struct Iter<'a, V> {
front: usize,
back: usize,
Expand All @@ -923,19 +924,6 @@ pub struct Iter<'a, V> {
iter: slice::Iter<'a, Option<V>>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Iter<'a, V> {
fn clone(&self) -> Iter<'a, V> {
Iter {
front: self.front,
back: self.back,
n: self.n,
yielded: self.yielded,
iter: self.iter.clone(),
}
}
}

iterator! { impl Iter -> (usize, &'a V), as_ref }
impl<'a, V> ExactSizeIterator for Iter<'a, V> {}

Check warning on line 928 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

warning: the following explicit lifetimes could be elided: 'a --> src/lib.rs:928:6 | 928 | impl<'a, V> ExactSizeIterator for Iter<'a, V> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 928 - impl<'a, V> ExactSizeIterator for Iter<'a, V> {} 928 + impl<V> ExactSizeIterator for Iter<'_, V> {} |
double_ended_iterator! { impl Iter -> (usize, &'a V), as_ref }
Expand All @@ -955,33 +943,17 @@ impl<'a, V> ExactSizeIterator for IterMut<'a, V> {}
double_ended_iterator! { impl IterMut -> (usize, &'a mut V), as_mut }

/// An iterator over the keys of a map.
#[derive(Clone)]
pub struct Keys<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Keys<'a, V> {
fn clone(&self) -> Keys<'a, V> {
Keys {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
#[derive(Clone)]
pub struct Values<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Values<'a, V> {
fn clone(&self) -> Values<'a, V> {
Values {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
pub struct ValuesMut<'a, V> {
iter_mut: IterMut<'a, V>,
Expand Down

0 comments on commit 11a0bd2

Please sign in to comment.