Skip to content

Commit 29d9c62

Browse files
author
blake2-ppc
committed
---
yaml --- r: 143073 b: refs/heads/try2 c: fe134b9 h: refs/heads/master i: 143071: 13e20d3 v: v3
1 parent 6e13caf commit 29d9c62

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 24b6901b26f0bde00706a5cbc16ffc29296ea40d
8+
refs/heads/try2: fe134b9509821e5e2fad5545cdd23c5325dfd583
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/dlist.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct Node<T> {
4747
}
4848

4949
/// Double-ended DList iterator
50+
#[deriving(Clone)]
5051
pub struct DListIterator<'self, T> {
5152
priv head: &'self Link<T>,
5253
priv tail: Rawlink<Node<T>>,
@@ -62,6 +63,7 @@ pub struct MutDListIterator<'self, T> {
6263
}
6364

6465
/// DList consuming iterator
66+
#[deriving(Clone)]
6567
pub struct ConsumeIterator<T> {
6668
priv list: DList<T>
6769
}
@@ -93,6 +95,13 @@ impl<T> Rawlink<T> {
9395
}
9496
}
9597

98+
impl<T> Clone for Rawlink<T> {
99+
#[inline]
100+
fn clone(&self) -> Rawlink<T> {
101+
Rawlink{p: self.p}
102+
}
103+
}
104+
96105
/// Set the .prev field on `next`, then return `Some(next)`
97106
fn link_with_prev<T>(mut next: ~Node<T>, prev: Rawlink<Node<T>>) -> Link<T> {
98107
next.prev = prev;
@@ -686,6 +695,20 @@ mod tests {
686695
assert_eq!(it.next(), None);
687696
}
688697

698+
#[test]
699+
fn test_iterator_clone() {
700+
let mut n = DList::new();
701+
n.push_back(2);
702+
n.push_back(3);
703+
n.push_back(4);
704+
let mut it = n.iter();
705+
it.next();
706+
let mut jt = it.clone();
707+
assert_eq!(it.next(), jt.next());
708+
assert_eq!(it.next_back(), jt.next_back());
709+
assert_eq!(it.next(), jt.next());
710+
}
711+
689712
#[test]
690713
fn test_iterator_double_end() {
691714
let mut n = DList::new();

0 commit comments

Comments
 (0)