Skip to content

Commit 6e13caf

Browse files
author
blake2-ppc
committed
---
yaml --- r: 143072 b: refs/heads/try2 c: 24b6901 h: refs/heads/master v: v3
1 parent 13e20d3 commit 6e13caf

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-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: ffe2623e47d9c5a5914865a9556cb1298ca00058
8+
refs/heads/try2: 24b6901b26f0bde00706a5cbc16ffc29296ea40d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/hashmap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ impl<K:Hash + Eq + Clone,V:Clone> Clone for HashMap<K,V> {
548548
}
549549

550550
/// HashMap iterator
551+
#[deriving(Clone)]
551552
pub struct HashMapIterator<'self, K, V> {
552553
priv iter: vec::VecIterator<'self, Option<Bucket<K, V>>>,
553554
}
@@ -563,6 +564,7 @@ pub struct HashMapConsumeIterator<K, V> {
563564
}
564565

565566
/// HashSet iterator
567+
#[deriving(Clone)]
566568
pub struct HashSetIterator<'self, K> {
567569
priv iter: vec::VecIterator<'self, Option<Bucket<K, ()>>>,
568570
}

branches/try2/src/libstd/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ impl<'self, C: CharEq> CharEq for &'self [C] {
288288

289289

290290
/// An iterator over the substrings of a string, separated by `sep`.
291+
#[deriving(Clone)]
291292
pub struct StrCharSplitIterator<'self,Sep> {
292293
priv string: &'self str,
293294
priv position: uint,
@@ -355,6 +356,7 @@ impl<'self, Sep: CharEq> Iterator<&'self str> for StrCharSplitIterator<'self, Se
355356

356357
/// An iterator over the start and end indicies of the matches of a
357358
/// substring within a larger string
359+
#[deriving(Clone)]
358360
pub struct StrMatchesIndexIterator<'self> {
359361
priv haystack: &'self str,
360362
priv needle: &'self str,
@@ -363,6 +365,7 @@ pub struct StrMatchesIndexIterator<'self> {
363365

364366
/// An iterator over the substrings of a string separated by a given
365367
/// search string
368+
#[deriving(Clone)]
366369
pub struct StrStrSplitIterator<'self> {
367370
priv it: StrMatchesIndexIterator<'self>,
368371
priv last_end: uint,
@@ -2269,6 +2272,7 @@ impl Clone for @str {
22692272
22702273
/// External iterator for a string's characters. Use with the `std::iterator`
22712274
/// module.
2275+
#[deriving(Clone)]
22722276
pub struct StrCharIterator<'self> {
22732277
priv index: uint,
22742278
priv string: &'self str,
@@ -2288,6 +2292,7 @@ impl<'self> Iterator<char> for StrCharIterator<'self> {
22882292
}
22892293
/// External iterator for a string's characters in reverse order. Use
22902294
/// with the `std::iterator` module.
2295+
#[deriving(Clone)]
22912296
pub struct StrCharRevIterator<'self> {
22922297
priv index: uint,
22932298
priv string: &'self str,
@@ -2308,6 +2313,7 @@ impl<'self> Iterator<char> for StrCharRevIterator<'self> {
23082313
23092314
/// External iterator for a string's bytes. Use with the `std::iterator`
23102315
/// module.
2316+
#[deriving(Clone)]
23112317
pub struct StrBytesIterator<'self> {
23122318
priv it: vec::VecIterator<'self, u8>
23132319
}
@@ -2321,6 +2327,7 @@ impl<'self> Iterator<u8> for StrBytesIterator<'self> {
23212327
23222328
/// External iterator for a string's bytes in reverse order. Use with
23232329
/// the `std::iterator` module.
2330+
#[deriving(Clone)]
23242331
pub struct StrBytesRevIterator<'self> {
23252332
priv it: vec::VecRevIterator<'self, u8>
23262333
}

branches/try2/src/libstd/vec.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,10 @@ iterator!{impl VecIterator -> &'self T}
22322232
double_ended_iterator!{impl VecIterator -> &'self T}
22332233
pub type VecRevIterator<'self, T> = InvertIterator<&'self T, VecIterator<'self, T>>;
22342234

2235+
impl<'self, T> Clone for VecIterator<'self, T> {
2236+
fn clone(&self) -> VecIterator<'self, T> { *self }
2237+
}
2238+
22352239
//iterator!{struct VecMutIterator -> *mut T, &'self mut T}
22362240
/// An iterator for mutating the elements of a vector.
22372241
pub struct VecMutIterator<'self, T> {
@@ -2244,6 +2248,7 @@ double_ended_iterator!{impl VecMutIterator -> &'self mut T}
22442248
pub type VecMutRevIterator<'self, T> = InvertIterator<&'self mut T, VecMutIterator<'self, T>>;
22452249

22462250
/// An iterator that moves out of a vector.
2251+
#[deriving(Clone)]
22472252
pub struct VecConsumeIterator<T> {
22482253
priv v: ~[T],
22492254
priv idx: uint,
@@ -2270,6 +2275,7 @@ impl<T> Iterator<T> for VecConsumeIterator<T> {
22702275
}
22712276

22722277
/// An iterator that moves out of a vector in reverse order.
2278+
#[deriving(Clone)]
22732279
pub struct VecConsumeRevIterator<T> {
22742280
priv v: ~[T]
22752281
}
@@ -3185,6 +3191,17 @@ mod tests {
31853191
assert_eq!(xs.mut_rev_iter().size_hint(), (5, Some(5)));
31863192
}
31873193

3194+
#[test]
3195+
fn test_iter_clone() {
3196+
let xs = [1, 2, 5];
3197+
let mut it = xs.iter();
3198+
it.next();
3199+
let mut jt = it.clone();
3200+
assert_eq!(it.next(), jt.next());
3201+
assert_eq!(it.next(), jt.next());
3202+
assert_eq!(it.next(), jt.next());
3203+
}
3204+
31883205
#[test]
31893206
fn test_mut_iterator() {
31903207
use iterator::*;

0 commit comments

Comments
 (0)