diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:11:09 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:11:09 -0700 |
| commit | ca7f7cf3d3bbac5dc3e35a28d89def398b6ec988 (patch) | |
| tree | 32555be8b258c50282cc59edb0fdd5207051730c | |
| parent | c7509bb8d88c46d2b0762a4892958bfea9e5d510 (diff) | |
| parent | 88edf9774caf32ff77e7bad096b624d37cd66b76 (diff) | |
| download | rust-ca7f7cf3d3bbac5dc3e35a28d89def398b6ec988.tar.gz rust-ca7f7cf3d3bbac5dc3e35a28d89def398b6ec988.zip | |
rollup merge of #23637: apasel422/iter
| -rw-r--r-- | src/libcollections/bit.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/linked_list.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/vec_deque.rs | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 25 |
4 files changed, 33 insertions, 1 deletions
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index e494527b6a6..79f7f193676 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -1804,12 +1804,16 @@ struct TwoBitPositions<'a> { next_idx: usize } +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Union<'a>(TwoBitPositions<'a>); +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Intersection<'a>(Take<TwoBitPositions<'a>>); +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Difference<'a>(TwoBitPositions<'a>); +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct SymmetricDifference<'a>(TwoBitPositions<'a>); diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 9e0a6d04381..9d30c0d9d42 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -832,6 +832,8 @@ impl<A> DoubleEndedIterator for IntoIter<A> { fn next_back(&mut self) -> Option<A> { self.list.pop_back() } } +impl<A> ExactSizeIterator for IntoIter<A> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<A> FromIterator<A> for LinkedList<A> { fn from_iter<T: IntoIterator<Item=A>>(iter: T) -> LinkedList<A> { diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 591ad48f579..feabc0bce57 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -556,7 +556,7 @@ impl<T> VecDeque<T> { } } - /// Consumes the list into an iterator yielding elements by value. + /// Consumes the list into a front-to-back iterator yielding elements by value. #[stable(feature = "rust1", since = "1.0.0")] pub fn into_iter(self) -> IntoIter<T> { IntoIter { @@ -1573,6 +1573,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} /// A by-value VecDeque iterator +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter<T> { inner: VecDeque<T>, 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<T, S> IntoIterator for HashSet<T, S> } } +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<usize>) { 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 |
