Skip to content

Commit 6b47fa7

Browse files
committed
---
yaml --- r: 72115 b: refs/heads/dist-snap c: 8ae6b33 h: refs/heads/master i: 72113: 588f5b4 72111: 20d9f07 v: v3
1 parent aafb068 commit 6b47fa7

File tree

4 files changed

+12
-101
lines changed

4 files changed

+12
-101
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 962a753890f801c378b3cb244b7d7ca3cae164a5
10+
refs/heads/dist-snap: 8ae6b33ed0cf2b1793773f31b8f5249347ef0983
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/iterator.rs

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ pub trait IteratorUtil<A> {
2222
// FIXME: #5898: should be called map
2323
fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, Self>;
2424
fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> FilterIterator<'r, A, Self>;
25-
fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhileIterator<'r, A, Self>;
26-
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, Self>;
27-
fn skip(self, n: uint) -> SkipIterator<Self>;
28-
fn take(self, n: uint) -> TakeIterator<Self>;
25+
fn dropwhile<'r>(self, predicate: &'r fn(&A) -> bool) -> DropWhileIterator<'r, A, Self>;
26+
fn takewhile<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, Self>;
2927
fn enumerate(self) -> EnumerateIterator<Self>;
3028
fn advance(&mut self, f: &fn(A) -> bool);
3129
}
@@ -53,25 +51,15 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
5351
}
5452

5553
#[inline(always)]
56-
fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhileIterator<'r, A, T> {
57-
SkipWhileIterator{iter: self, flag: false, predicate: predicate}
54+
fn dropwhile<'r>(self, predicate: &'r fn(&A) -> bool) -> DropWhileIterator<'r, A, T> {
55+
DropWhileIterator{iter: self, flag: false, predicate: predicate}
5856
}
5957

6058
#[inline(always)]
61-
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, T> {
59+
fn takewhile<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, T> {
6260
TakeWhileIterator{iter: self, flag: false, predicate: predicate}
6361
}
6462

65-
#[inline(always)]
66-
fn skip(self, n: uint) -> SkipIterator<T> {
67-
SkipIterator{iter: self, n: n}
68-
}
69-
70-
#[inline(always)]
71-
fn take(self, n: uint) -> TakeIterator<T> {
72-
TakeIterator{iter: self, n: n}
73-
}
74-
7563
/// A shim implementing the `for` loop iteration protocol for iterator objects
7664
#[inline]
7765
fn advance(&mut self, f: &fn(A) -> bool) {
@@ -154,13 +142,13 @@ impl<A, T: Iterator<A>> Iterator<(uint, A)> for EnumerateIterator<T> {
154142
}
155143
}
156144

157-
pub struct SkipWhileIterator<'self, A, T> {
145+
pub struct DropWhileIterator<'self, A, T> {
158146
priv iter: T,
159147
priv flag: bool,
160148
priv predicate: &'self fn(&A) -> bool
161149
}
162150

163-
impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhileIterator<'self, A, T> {
151+
impl<'self, A, T: Iterator<A>> Iterator<A> for DropWhileIterator<'self, A, T> {
164152
#[inline]
165153
fn next(&mut self) -> Option<A> {
166154
let mut next = self.iter.next();
@@ -211,52 +199,3 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhileIterator<'self, A, T> {
211199
}
212200
}
213201
}
214-
215-
pub struct SkipIterator<T> {
216-
priv iter: T,
217-
priv n: uint
218-
}
219-
220-
impl<A, T: Iterator<A>> Iterator<A> for SkipIterator<T> {
221-
#[inline]
222-
fn next(&mut self) -> Option<A> {
223-
let mut next = self.iter.next();
224-
if self.n == 0 {
225-
next
226-
} else {
227-
let n = self.n;
228-
for n.times {
229-
match next {
230-
Some(_) => {
231-
next = self.iter.next();
232-
loop
233-
}
234-
None => {
235-
self.n = 0;
236-
return None
237-
}
238-
}
239-
}
240-
self.n = 0;
241-
next
242-
}
243-
}
244-
}
245-
246-
pub struct TakeIterator<T> {
247-
priv iter: T,
248-
priv n: uint
249-
}
250-
251-
impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
252-
#[inline]
253-
fn next(&mut self) -> Option<A> {
254-
let next = self.iter.next();
255-
if self.n != 0 {
256-
self.n -= 1;
257-
next
258-
} else {
259-
None
260-
}
261-
}
262-
}

branches/dist-snap/src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ pub fn char_range_at(s: &str, i: uint) -> CharRange {
18631863
return CharRange {ch: val as char, next: i};
18641864
}
18651865

1866-
/// Plucks the `n`th character from the beginning of a string
1866+
/// Plucks the character starting at the `i`th byte of a string
18671867
pub fn char_at(s: &str, i: uint) -> char {
18681868
return char_range_at(s, i).ch;
18691869
}
@@ -1874,11 +1874,11 @@ pub struct CharRange {
18741874
}
18751875

18761876
/**
1877-
* Given a byte position and a str, return the previous char and its position
1877+
* Given a byte position and a str, return the previous char and its position.
18781878
*
18791879
* This function can be used to iterate over a unicode string in reverse.
18801880
*
1881-
* returns 0 for next index if called on start index 0
1881+
* Returns 0 for next index if called on start index 0.
18821882
*/
18831883
pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
18841884
let mut prev = start;
@@ -1900,7 +1900,7 @@ pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
19001900
return CharRange {ch:ch, next:prev};
19011901
}
19021902

1903-
/// Plucks the `n`th character from the end of a string
1903+
/// Plucks the character ending at the `i`th byte of a string
19041904
pub fn char_at_reverse(s: &str, i: uint) -> char {
19051905
char_range_at_reverse(s, i).ch
19061906
}

branches/dist-snap/src/libcore/vec.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4512,32 +4512,4 @@ mod tests {
45124512
}
45134513
assert_eq!(i, ys.len());
45144514
}
4515-
4516-
#[test]
4517-
fn test_iterator_skip() {
4518-
use iterator::*;
4519-
let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
4520-
let ys = [13, 15, 16, 17, 19, 20, 30];
4521-
let mut it = xs.iter().skip(5);
4522-
let mut i = 0;
4523-
for it.advance |&x: &uint| {
4524-
assert_eq!(x, ys[i]);
4525-
i += 1;
4526-
}
4527-
assert_eq!(i, ys.len());
4528-
}
4529-
4530-
#[test]
4531-
fn test_iterator_take() {
4532-
use iterator::*;
4533-
let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
4534-
let ys = [0u, 1, 2, 3, 5];
4535-
let mut it = xs.iter().take(5);
4536-
let mut i = 0;
4537-
for it.advance |&x: &uint| {
4538-
assert_eq!(x, ys[i]);
4539-
i += 1;
4540-
}
4541-
assert_eq!(i, ys.len());
4542-
}
45434515
}

0 commit comments

Comments
 (0)