From 8f840f9ea0a60e05d3d587d64c9e178c0af1e227 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 3 Sep 2012 15:58:01 -0700 Subject: libstd: Implement a Sort trait. This depends on the previous fix to not assert. --- src/libstd/sort.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 07552a0a94f..00396e0e773 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -9,6 +9,7 @@ export le; export merge_sort; export quick_sort; export quick_sort3; +export Sort; type le = pure fn(v1: &T, v2: &T) -> bool; @@ -160,6 +161,14 @@ fn quick_sort3(arr: &[mut T]) { qsort3(arr, 0, (arr.len() - 1) as int); } +trait Sort { + fn qsort(self); +} + +impl &[mut T] : Sort { + fn qsort(self) { quick_sort3(self); } +} + #[cfg(test)] mod test_qsort3 { fn check_sort(v1: &[mut int], v2: &[mut int]) { -- cgit 1.4.1-3-g733a5