Skip to content

Commit 908e901

Browse files
committed
---
yaml --- r: 63757 b: refs/heads/snap-stage3 c: ae2f185 h: refs/heads/master i: 63755: ac58641 v: v3
1 parent 0950890 commit 908e901

File tree

3 files changed

+30
-49
lines changed

3 files changed

+30
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 206d4f00dc628cf0c7680ae2dc5b3ab6771c32e4
4+
refs/heads/snap-stage3: ae2f1853491540b9e70be2209b235f6c920706a8
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fn run_tests(opts: &TestOpts,
431431
callback(TeFiltered(filtered_descs));
432432
433433
let (filtered_tests, filtered_benchs) =
434-
do vec::partition(filtered_tests) |e| {
434+
do filtered_tests.partition |e| {
435435
match e.testfn {
436436
StaticTestFn(_) | DynTestFn(_) => true,
437437
StaticBenchFn(_) | DynBenchFn(_) => false

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -337,46 +337,6 @@ pub fn rsplitn<T:Copy>(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]] {
337337
result
338338
}
339339

340-
/**
341-
* Partitions a vector into two new vectors: those that satisfies the
342-
* predicate, and those that do not.
343-
*/
344-
pub fn partition<T>(v: ~[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) {
345-
let mut lefts = ~[];
346-
let mut rights = ~[];
347-
348-
// FIXME (#4355 maybe): using v.consume here crashes
349-
// do v.consume |_, elt| {
350-
do consume(v) |_, elt| {
351-
if f(&elt) {
352-
lefts.push(elt);
353-
} else {
354-
rights.push(elt);
355-
}
356-
}
357-
358-
(lefts, rights)
359-
}
360-
361-
/**
362-
* Partitions a vector into two new vectors: those that satisfies the
363-
* predicate, and those that do not.
364-
*/
365-
pub fn partitioned<T:Copy>(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) {
366-
let mut lefts = ~[];
367-
let mut rights = ~[];
368-
369-
for v.iter().advance |elt| {
370-
if f(elt) {
371-
lefts.push(copy *elt);
372-
} else {
373-
rights.push(copy *elt);
374-
}
375-
}
376-
377-
(lefts, rights)
378-
}
379-
380340
/// Consumes all elements, in a vector, moving them out into the / closure
381341
/// provided. The vector is traversed from the start to the end.
382342
///
@@ -1572,7 +1532,18 @@ impl<'self,T:Copy> ImmutableCopyableVector<T> for &'self [T] {
15721532
*/
15731533
#[inline]
15741534
fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]) {
1575-
partitioned(*self, f)
1535+
let mut lefts = ~[];
1536+
let mut rights = ~[];
1537+
1538+
for self.iter().advance |elt| {
1539+
if f(elt) {
1540+
lefts.push(copy *elt);
1541+
} else {
1542+
rights.push(copy *elt);
1543+
}
1544+
}
1545+
1546+
(lefts, rights)
15761547
}
15771548

15781549
/// Returns the element at the given index, without doing bounds checking.
@@ -1842,7 +1813,18 @@ impl<T> OwnedVector<T> for ~[T] {
18421813
*/
18431814
#[inline]
18441815
fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]) {
1845-
partition(self, f)
1816+
let mut lefts = ~[];
1817+
let mut rights = ~[];
1818+
1819+
do self.consume |_, elt| {
1820+
if f(&elt) {
1821+
lefts.push(elt);
1822+
} else {
1823+
rights.push(elt);
1824+
}
1825+
}
1826+
1827+
(lefts, rights)
18461828
}
18471829

18481830
#[inline]
@@ -3228,11 +3210,10 @@ mod tests {
32283210

32293211
#[test]
32303212
fn test_partition() {
3231-
// FIXME (#4355 maybe): using v.partition here crashes
3232-
assert_eq!(partition(~[], |x: &int| *x < 3), (~[], ~[]));
3233-
assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 4), (~[1, 2, 3], ~[]));
3234-
assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 2), (~[1], ~[2, 3]));
3235-
assert_eq!(partition(~[1, 2, 3], |x: &int| *x < 0), (~[], ~[1, 2, 3]));
3213+
assert_eq!((~[]).partition(|x: &int| *x < 3), (~[], ~[]));
3214+
assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 4), (~[1, 2, 3], ~[]));
3215+
assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 2), (~[1], ~[2, 3]));
3216+
assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 0), (~[], ~[1, 2, 3]));
32363217
}
32373218

32383219
#[test]

0 commit comments

Comments
 (0)