From 64532f7f0001e4627be839d877ded1ba0326b615 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Mon, 23 Mar 2015 08:50:47 -0400 Subject: implement `Clone` for various iterators --- src/libstd/collections/hash/set.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/libstd/collections') diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index de3f080de82..8d69ab430d3 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -853,6 +853,9 @@ impl IntoIterator for HashSet } } +impl<'a, K> Clone for Iter<'a, K> { + fn clone(&self) -> Iter<'a, K> { Iter { iter: self.iter.clone() } } +} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K> Iterator for Iter<'a, K> { type Item = &'a K; @@ -889,6 +892,12 @@ impl<'a, K> ExactSizeIterator for Drain<'a, K> { fn len(&self) -> usize { self.iter.len() } } +impl<'a, T, S> Clone for Intersection<'a, T, S> { + fn clone(&self) -> Intersection<'a, T, S> { + Intersection { iter: self.iter.clone(), ..*self } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T, S> Iterator for Intersection<'a, T, S> where T: Eq + Hash, S: HashState @@ -912,6 +921,12 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S> } } +impl<'a, T, S> Clone for Difference<'a, T, S> { + fn clone(&self) -> Difference<'a, T, S> { + Difference { iter: self.iter.clone(), ..*self } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T, S> Iterator for Difference<'a, T, S> where T: Eq + Hash, S: HashState @@ -935,6 +950,12 @@ impl<'a, T, S> Iterator for Difference<'a, T, S> } } +impl<'a, T, S> Clone for SymmetricDifference<'a, T, S> { + fn clone(&self) -> SymmetricDifference<'a, T, S> { + SymmetricDifference { iter: self.iter.clone() } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S> where T: Eq + Hash, S: HashState @@ -945,6 +966,10 @@ impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S> fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } +impl<'a, T, S> Clone for Union<'a, T, S> { + fn clone(&self) -> Union<'a, T, S> { Union { iter: self.iter.clone() } } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T, S> Iterator for Union<'a, T, S> where T: Eq + Hash, S: HashState -- cgit 1.4.1-3-g733a5