Skip to content

Commit d39fe02

Browse files
committed
---
yaml --- r: 59091 b: refs/heads/incoming c: 35e6ce5 h: refs/heads/master i: 59089: d6049b9 59087: f714978 v: v3
1 parent 7703c51 commit d39fe02

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
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: f2f10bdc7a2f1d1501abb04f3625356c0c251d92
9+
refs/heads/incoming: 35e6ce548f2008331c0fa50f1cff30ab7b412ab7
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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/incoming/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)