Skip to content

Commit 0f5de4e

Browse files
author
blake2-ppc
committed
---
yaml --- r: 67519 b: refs/heads/master c: 02bdf90 h: refs/heads/master i: 67517: 4bf1c4d 67515: 3584201 67511: ed8f504 67503: 54ebd86 67487: 43bbe50 67455: 5644228 v: v3
1 parent 68182d6 commit 0f5de4e

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6d7a0c8cbcd81242d12ad41e0d13c2408c73c8ac
2+
refs/heads/master: 02bdf90cf6509f0f308ce133551a833c264b8960
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/iter.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ pub trait FromIter<T> {
7272
#[inline]
7373
pub fn any<T>(predicate: &fn(T) -> bool,
7474
iter: &fn(f: &fn(T) -> bool) -> bool) -> bool {
75-
for iter |x| {
76-
if predicate(x) {
77-
return true;
78-
}
75+
do iter |x| {
76+
predicate(x)
7977
}
80-
return false;
8178
}
8279

8380
/**
@@ -111,12 +108,14 @@ pub fn all<T>(predicate: &fn(T) -> bool,
111108
#[inline]
112109
pub fn find<T>(predicate: &fn(&T) -> bool,
113110
iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
114-
for iter |x| {
111+
let mut ret = None;
112+
do iter |x| {
115113
if predicate(&x) {
116-
return Some(x);
117-
}
118-
}
119-
None
114+
ret = Some(x);
115+
false
116+
} else { true }
117+
};
118+
ret
120119
}
121120

122121
/**
@@ -132,7 +131,7 @@ pub fn find<T>(predicate: &fn(&T) -> bool,
132131
#[inline]
133132
pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
134133
let mut result = None;
135-
for iter |x| {
134+
do iter |x| {
136135
match result {
137136
Some(ref mut y) => {
138137
if x > *y {
@@ -141,7 +140,8 @@ pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
141140
}
142141
None => result = Some(x)
143142
}
144-
}
143+
true
144+
};
145145
result
146146
}
147147

@@ -158,7 +158,7 @@ pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
158158
#[inline]
159159
pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
160160
let mut result = None;
161-
for iter |x| {
161+
do iter |x| {
162162
match result {
163163
Some(ref mut y) => {
164164
if x < *y {
@@ -167,7 +167,8 @@ pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
167167
}
168168
None => result = Some(x)
169169
}
170-
}
170+
true
171+
};
171172
result
172173
}
173174

@@ -183,9 +184,10 @@ pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
183184
#[inline]
184185
pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T, U)) -> T {
185186
let mut result = start;
186-
for iter |x| {
187+
do iter |x| {
187188
f(&mut result, x);
188-
}
189+
true
190+
};
189191
result
190192
}
191193

@@ -206,9 +208,10 @@ pub fn fold<T, U>(start: T, iter: &fn(f: &fn(U) -> bool) -> bool, f: &fn(&mut T,
206208
#[inline]
207209
pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&mut T, &U)) -> T {
208210
let mut result = start;
209-
for iter |x| {
211+
do iter |x| {
210212
f(&mut result, x);
211-
}
213+
true
214+
};
212215
result
213216
}
214217

@@ -246,7 +249,7 @@ impl<T> FromIter<T> for ~[T]{
246249
#[inline]
247250
pub fn from_iter(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] {
248251
let mut v = ~[];
249-
for iter |x| { v.push(x) }
252+
do iter |x| { v.push(x); true };
250253
v
251254
}
252255
}

0 commit comments

Comments
 (0)