Skip to content

Commit c611bc6

Browse files
committed
---
yaml --- r: 58350 b: refs/heads/auto c: 35e6ce5 h: refs/heads/master v: v3
1 parent 9c9cd74 commit c611bc6

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: f2f10bdc7a2f1d1501abb04f3625356c0c251d92
17+
refs/heads/auto: 35e6ce548f2008331c0fa50f1cff30ab7b412ab7
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/old_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub trait CopyableNonstrictIter<A:Copy> {
9393
// Like "each", but copies out the value. If the receiver is mutated while
9494
// iterating over it, the semantics must not be memory-unsafe but are
9595
// otherwise undefined.
96-
fn each_val(&const self, f: &fn(A) -> bool);
96+
fn each_val(&const self, f: &fn(A) -> bool) -> bool;
9797
}
9898

9999
// A trait for sequences that can be built by imperatively pushing elements

branches/auto/src/libcore/vec.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,34 +2945,37 @@ impl<A:Copy + Ord> old_iter::CopyableOrderedIter<A> for @[A] {
29452945
}
29462946

29472947
impl<'self,A:Copy> old_iter::CopyableNonstrictIter<A> for &'self [A] {
2948-
fn each_val(&const self, f: &fn(A) -> bool) {
2948+
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
29492949
let mut i = 0;
29502950
while i < self.len() {
2951-
if !f(copy self[i]) { break; }
2951+
if !f(copy self[i]) { return false; }
29522952
i += 1;
29532953
}
2954+
return true;
29542955
}
29552956
}
29562957

29572958
// FIXME(#4148): This should be redundant
29582959
impl<A:Copy> old_iter::CopyableNonstrictIter<A> for ~[A] {
2959-
fn each_val(&const self, f: &fn(A) -> bool) {
2960+
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
29602961
let mut i = 0;
29612962
while i < uniq_len(self) {
2962-
if !f(copy self[i]) { break; }
2963+
if !f(copy self[i]) { return false; }
29632964
i += 1;
29642965
}
2966+
return true;
29652967
}
29662968
}
29672969

29682970
// FIXME(#4148): This should be redundant
29692971
impl<A:Copy> old_iter::CopyableNonstrictIter<A> for @[A] {
2970-
fn each_val(&const self, f: &fn(A) -> bool) {
2972+
fn each_val(&const self, f: &fn(A) -> bool) -> bool {
29712973
let mut i = 0;
29722974
while i < self.len() {
2973-
if !f(copy self[i]) { break; }
2975+
if !f(copy self[i]) { return false; }
29742976
i += 1;
29752977
}
2978+
return true;
29762979
}
29772980
}
29782981

@@ -4688,4 +4691,14 @@ mod tests {
46884691
i += 1;
46894692
}
46904693
}
4694+
4695+
#[test]
4696+
fn test_each_val() {
4697+
use old_iter::CopyableNonstrictIter;
4698+
let mut i = 0;
4699+
for [1, 2, 3].each_val |v| {
4700+
i += v;
4701+
}
4702+
assert!(i == 6);
4703+
}
46914704
}

0 commit comments

Comments
 (0)