rollup merge of #23604: apasel422/btree

`btree_map::IntoIter` (and `btree_set::IntoIter`) remains, but it is a bit trickier.
This commit is contained in:
Alex Crichton 2015-03-23 15:10:51 -07:00
commit 68fb3acd85
3 changed files with 41 additions and 0 deletions

View file

@ -78,6 +78,7 @@ pub struct BTreeMap<K, V> {
}
/// An abstract base over-which all other BTree iterators are built.
#[derive(Clone)]
struct AbsIter<T> {
traversals: VecDeque<T>,
size: usize,
@ -1040,6 +1041,9 @@ impl<K, V, E, T> DoubleEndedIterator for AbsIter<T> where
}
}
impl<'a, K, V> Clone for Iter<'a, K, V> {
fn clone(&self) -> Iter<'a, K, V> { Iter { inner: self.inner.clone() } }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Iterator for Iter<'a, K, V> {
type Item = (&'a K, &'a V);
@ -1082,6 +1086,9 @@ impl<K, V> DoubleEndedIterator for IntoIter<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<K, V> ExactSizeIterator for IntoIter<K, V> {}
impl<'a, K, V> Clone for Keys<'a, K, V> {
fn clone(&self) -> Keys<'a, K, V> { Keys { inner: self.inner.clone() } }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Iterator for Keys<'a, K, V> {
type Item = &'a K;
@ -1097,6 +1104,9 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {}
impl<'a, K, V> Clone for Values<'a, K, V> {
fn clone(&self) -> Values<'a, K, V> { Values { inner: self.inner.clone() } }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Iterator for Values<'a, K, V> {
type Item = &'a V;
@ -1111,6 +1121,9 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
impl<'a, K, V> Clone for Range<'a, K, V> {
fn clone(&self) -> Range<'a, K, V> { Range { inner: self.inner.clone() } }
}
impl<'a, K, V> Iterator for Range<'a, K, V> {
type Item = (&'a K, &'a V);

View file

@ -1326,6 +1326,7 @@ trait TraversalImpl {
/// A `TraversalImpl` that actually is backed by two iterators. This works in the non-moving case,
/// as no deallocation needs to be done.
#[derive(Clone)]
struct ElemsAndEdges<Elems, Edges>(Elems, Edges);
impl<K, V, E, Elems: DoubleEndedIterator, Edges: DoubleEndedIterator>
@ -1404,6 +1405,7 @@ impl<K, V> Drop for MoveTraversalImpl<K, V> {
}
/// An abstraction over all the different kinds of traversals a node supports
#[derive(Clone)]
struct AbsTraversal<Impl> {
inner: Impl,
head_is_edge: bool,

View file

@ -628,6 +628,9 @@ impl<T: Debug> Debug for BTreeSet<T> {
}
}
impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> { Iter { iter: self.iter.clone() } }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;
@ -658,6 +661,9 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {}
impl<'a, T> Clone for Range<'a, T> {
fn clone(&self) -> Range<'a, T> { Range { iter: self.iter.clone() } }
}
impl<'a, T> Iterator for Range<'a, T> {
type Item = &'a T;
@ -677,6 +683,11 @@ fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,
}
}
impl<'a, T> Clone for Difference<'a, T> {
fn clone(&self) -> Difference<'a, T> {
Difference { a: self.a.clone(), b: self.b.clone() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: Ord> Iterator for Difference<'a, T> {
type Item = &'a T;
@ -692,6 +703,11 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
}
}
impl<'a, T> Clone for SymmetricDifference<'a, T> {
fn clone(&self) -> SymmetricDifference<'a, T> {
SymmetricDifference { a: self.a.clone(), b: self.b.clone() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
type Item = &'a T;
@ -707,6 +723,11 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
}
}
impl<'a, T> Clone for Intersection<'a, T> {
fn clone(&self) -> Intersection<'a, T> {
Intersection { a: self.a.clone(), b: self.b.clone() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: Ord> Iterator for Intersection<'a, T> {
type Item = &'a T;
@ -728,6 +749,11 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
}
}
impl<'a, T> Clone for Union<'a, T> {
fn clone(&self) -> Union<'a, T> {
Union { a: self.a.clone(), b: self.b.clone() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: Ord> Iterator for Union<'a, T> {
type Item = &'a T;