Skip to content

Commit 3fd3b1a

Browse files
committed
---
yaml --- r: 37463 b: refs/heads/try c: ad02510 h: refs/heads/master i: 37461: 864df01 37459: 1a4c2da 37455: 9370a9b v: v3
1 parent ea5566e commit 3fd3b1a

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: 0c2e6fda73918784ad2512c96c9b2f4787bbd72b
5+
refs/heads/try: ad025102582b8c5b7d78b96683cf9e9e94dc5272
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libcore/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use vec::{ConstVector, CopyableVector, ImmutableVector};
1717
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
1818
pub use vec::{MutableVector, MutableCopyableVector};
1919
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
20-
pub use iter::{CopyableOrderedIter, Times};
20+
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
2121
pub use num::Num;
2222
pub use ptr::Ptr;
2323
pub use to_str::ToStr;

branches/try/src/libcore/iter.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ pub trait CopyableOrderedIter<A:Copy Ord> {
4646
pure fn max() -> A;
4747
}
4848

49+
pub trait CopyableNonstrictIter<A:Copy> {
50+
// Like "each", but copies out the value. If the receiver is mutated while
51+
// iterating over it, the semantics must not be memory-unsafe but are
52+
// otherwise undefined.
53+
pure fn each_val(&const self, f: &fn(A) -> bool);
54+
}
55+
4956
// A trait for sequences that can be by imperatively pushing elements
5057
// onto them.
5158
pub trait Buildable<A> {

branches/try/src/libcore/vec.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,37 @@ impl<A: Copy Ord> &[A]: iter::CopyableOrderedIter<A> {
20202020
pure fn min() -> A { iter::min(&self) }
20212021
pure fn max() -> A { iter::max(&self) }
20222022
}
2023+
2024+
impl<A:Copy> &[A] : iter::CopyableNonstrictIter<A> {
2025+
pure fn each_val(&const self, f: fn(A) -> bool) {
2026+
let mut i = 0;
2027+
while i < self.len() {
2028+
if !f(copy self[i]) { break; }
2029+
i += 1;
2030+
}
2031+
}
2032+
}
2033+
2034+
impl<A:Copy> ~[A] : iter::CopyableNonstrictIter<A> {
2035+
pure fn each_val(&const self, f: fn(A) -> bool) {
2036+
let mut i = 0;
2037+
while i < self.len() {
2038+
if !f(copy self[i]) { break; }
2039+
i += 1;
2040+
}
2041+
}
2042+
}
2043+
2044+
impl<A:Copy> @[A] : iter::CopyableNonstrictIter<A> {
2045+
pure fn each_val(&const self, f: fn(A) -> bool) {
2046+
let mut i = 0;
2047+
while i < self.len() {
2048+
if !f(copy self[i]) { break; }
2049+
i += 1;
2050+
}
2051+
}
2052+
}
2053+
20232054
// ___________________________________________________________________________
20242055

20252056
#[cfg(test)]

0 commit comments

Comments
 (0)