diff options
| author | Nick Whitney <ubersentinel@gmail.com> | 2017-06-06 01:31:46 -0400 |
|---|---|---|
| committer | Nick Whitney <ubersentinel@gmail.com> | 2017-06-06 22:42:48 -0400 |
| commit | 2cadc32b66e135eeb9ac22d433cd931b021792a5 (patch) | |
| tree | bfccae0612ff6fe569a77fdf6976358d690b3f7d /src/libcore/tests | |
| parent | 76242aebb9d47558124c991a6faf0eb706d35703 (diff) | |
Add max and min default fns to Ord trait
Pursuant to issue #25663, this commit adds the max and min functions to the Ord trait, enabling items that implement Ord to use UFCS (ex. 1.max(2)) instead of the longer std::cmp::max(1,2) format.
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/cmp.rs | 10 | ||||
| -rw-r--r-- | src/libcore/tests/lib.rs | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/tests/cmp.rs b/src/libcore/tests/cmp.rs index e3c65ad8b33..8c5179f5993 100644 --- a/src/libcore/tests/cmp.rs +++ b/src/libcore/tests/cmp.rs @@ -29,6 +29,16 @@ fn test_mut_int_totalord() { } #[test] +fn test_ord_max_min() { + assert_eq!(1.max(2), 2); + assert_eq!(2.max(1), 2); + assert_eq!(1.min(2), 1); + assert_eq!(2.min(1), 1); + assert_eq!(1.max(1), 1); + assert_eq!(1.min(1), 1); +} + +#[test] fn test_ordering_reverse() { assert_eq!(Less.reverse(), Greater); assert_eq!(Equal.reverse(), Equal); diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 505e51fa80b..77a9307f43e 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -26,6 +26,7 @@ #![feature(iter_rfind)] #![feature(libc)] #![feature(nonzero)] +#![feature(ord_max_min)] #![feature(rand)] #![feature(raw)] #![feature(sip_hash_13)] |
