Skip to content

Commit c0a1bc5

Browse files
committed
---
yaml --- r: 38847 b: refs/heads/incoming c: ad02510 h: refs/heads/master i: 38845: 636df2a 38843: 3d8d212 38839: dcbadba 38831: 6cbbcb7 38815: c562212 38783: a113211 v: v3
1 parent dad117a commit c0a1bc5

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
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 0c2e6fda73918784ad2512c96c9b2f4787bbd72b
9+
refs/heads/incoming: ad025102582b8c5b7d78b96683cf9e9e94dc5272
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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