Skip to content

Commit 8f840f9

Browse files
committed
libstd: Implement a Sort trait.
This depends on the previous fix to not assert.
1 parent 5573ad7 commit 8f840f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libstd/sort.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export le;
99
export merge_sort;
1010
export quick_sort;
1111
export quick_sort3;
12+
export Sort;
1213

1314
type le<T> = pure fn(v1: &T, v2: &T) -> bool;
1415

@@ -160,6 +161,14 @@ fn quick_sort3<T: copy Ord Eq>(arr: &[mut T]) {
160161
qsort3(arr, 0, (arr.len() - 1) as int);
161162
}
162163

164+
trait Sort {
165+
fn qsort(self);
166+
}
167+
168+
impl<T: copy Ord Eq> &[mut T] : Sort {
169+
fn qsort(self) { quick_sort3(self); }
170+
}
171+
163172
#[cfg(test)]
164173
mod test_qsort3 {
165174
fn check_sort(v1: &[mut int], v2: &[mut int]) {

0 commit comments

Comments
 (0)