From b9e130714e1837b46f8e77a6f89f1fb99af31fdd Mon Sep 17 00:00:00 2001 From: LighghtEeloo Date: Fri, 19 May 2023 23:17:20 +0800 Subject: [PATCH] use derive macro for `impl Clone` --- src/lib.rs | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 209ef7c..974f859 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -912,6 +912,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, @@ -920,19 +921,6 @@ pub struct Iter<'a, V> { iter: slice::Iter<'a, Option>, } -// 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> {} double_ended_iterator! { impl Iter -> (usize, &'a V), as_ref } @@ -952,33 +940,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>,