Skip to content

Commit 182eea9

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163294 b: refs/heads/snap-stage3 c: a7a065b h: refs/heads/master v: v3
1 parent 59310e5 commit 182eea9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
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: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6f19f8d43051f8c8dff81ed0c82ca2d9026d58a8
4+
refs/heads/snap-stage3: a7a065bd98e9959d09362ca4982c2f7226ddc94b
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcollections/slice.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ use core::cmp;
9494
use core::kinds::{Copy, Sized};
9595
use core::mem::size_of;
9696
use core::mem;
97+
use core::ops::FnMut;
9798
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
9899
use core::prelude::{Ord, Ordering, RawPtr, Some, range};
99100
use core::ptr;
@@ -296,7 +297,7 @@ pub trait CloneSliceAllocPrelude<T> for Sized? {
296297

297298
/// Partitions the vector into two vectors `(a, b)`, where all
298299
/// elements of `a` satisfy `f` and all elements of `b` do not.
299-
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>);
300+
fn partitioned<F>(&self, f: F) -> (Vec<T>, Vec<T>) where F: FnMut(&T) -> bool;
300301

301302
/// Creates an iterator that yields every possible permutation of the
302303
/// vector in succession.
@@ -336,7 +337,7 @@ impl<T: Clone> CloneSliceAllocPrelude<T> for [T] {
336337

337338

338339
#[inline]
339-
fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
340+
fn partitioned<F>(&self, mut f: F) -> (Vec<T>, Vec<T>) where F: FnMut(&T) -> bool {
340341
let mut lefts = Vec::new();
341342
let mut rights = Vec::new();
342343

@@ -361,7 +362,7 @@ impl<T: Clone> CloneSliceAllocPrelude<T> for [T] {
361362

362363
}
363364

364-
fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
365+
fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering {
365366
let len = v.len() as int;
366367
let buf_v = v.as_mut_ptr();
367368

@@ -403,7 +404,7 @@ fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
403404
}
404405
}
405406

406-
fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
407+
fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering {
407408
// warning: this wildly uses unsafe.
408409
static BASE_INSERTION: uint = 32;
409410
static LARGE_INSERTION: uint = 16;
@@ -611,7 +612,7 @@ pub trait SliceAllocPrelude<T> for Sized? {
611612
/// v.sort_by(|a, b| b.cmp(a));
612613
/// assert!(v == [5, 4, 3, 2, 1]);
613614
/// ```
614-
fn sort_by(&mut self, compare: |&T, &T| -> Ordering);
615+
fn sort_by<F>(&mut self, compare: F) where F: FnMut(&T, &T) -> Ordering;
615616

616617
/// Consumes `src` and moves as many elements as it can into `self`
617618
/// from the range [start,end).
@@ -639,7 +640,7 @@ pub trait SliceAllocPrelude<T> for Sized? {
639640

640641
impl<T> SliceAllocPrelude<T> for [T] {
641642
#[inline]
642-
fn sort_by(&mut self, compare: |&T, &T| -> Ordering) {
643+
fn sort_by<F>(&mut self, compare: F) where F: FnMut(&T, &T) -> Ordering {
643644
merge_sort(self, compare)
644645
}
645646

0 commit comments

Comments
 (0)