]> git.proxmox.com Git - rustc.git/blobdiff - src/libcore/cmp.rs
Move away from hash to the same rust naming schema
[rustc.git] / src / libcore / cmp.rs
index 9d151abea787c97c6188dc8b4d19248566987ce4..aea5feb4be1ff4e942892bd4a7b5e0334d5700e0 100644 (file)
@@ -19,8 +19,9 @@
 
 use self::Ordering::*;
 
+use mem;
 use marker::Sized;
-use option::Option::{self, Some, None};
+use option::Option::{self, Some};
 
 /// Trait for equality comparisons which are [partial equivalence
 /// relations](http://en.wikipedia.org/wiki/Partial_equivalence_relation).
@@ -114,6 +115,10 @@ pub enum Ordering {
 }
 
 impl Ordering {
+    unsafe fn from_i8_unchecked(v: i8) -> Ordering {
+        mem::transmute(v)
+    }
+
     /// Reverse the `Ordering`.
     ///
     /// * `Less` becomes `Greater`.
@@ -155,7 +160,7 @@ impl Ordering {
             //
             // NB. it is safe because of the explicit discriminants
             // given above.
-            ::mem::transmute::<_, Ordering>(-(self as i8))
+            Ordering::from_i8_unchecked(-(self as i8))
         }
     }
 }
@@ -376,78 +381,6 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
     if v2 >= v1 { v2 } else { v1 }
 }
 
-/// Compare and return the minimum of two values if there is one.
-///
-/// Returns the first argument if the comparison determines them to be equal.
-///
-/// # Examples
-///
-/// ```
-/// #![feature(cmp_partial)]
-///
-/// use std::cmp;
-///
-/// assert_eq!(Some(1), cmp::partial_min(1, 2));
-/// assert_eq!(Some(2), cmp::partial_min(2, 2));
-/// ```
-///
-/// When comparison is impossible:
-///
-/// ```
-/// #![feature(cmp_partial)]
-///
-/// use std::cmp;
-///
-/// let result = cmp::partial_min(std::f64::NAN, 1.0);
-/// assert_eq!(result, None);
-/// ```
-#[inline]
-#[unstable(feature = "cmp_partial")]
-#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")]
-pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
-    match v1.partial_cmp(&v2) {
-        Some(Less) | Some(Equal) => Some(v1),
-        Some(Greater) => Some(v2),
-        None => None
-    }
-}
-
-/// Compare and return the maximum of two values if there is one.
-///
-/// Returns the second argument if the comparison determines them to be equal.
-///
-/// # Examples
-///
-/// ```
-/// #![feature(cmp_partial)]
-///
-/// use std::cmp;
-///
-/// assert_eq!(Some(2), cmp::partial_max(1, 2));
-/// assert_eq!(Some(2), cmp::partial_max(2, 2));
-/// ```
-///
-/// When comparison is impossible:
-///
-/// ```
-/// #![feature(cmp_partial)]
-///
-/// use std::cmp;
-///
-/// let result = cmp::partial_max(std::f64::NAN, 1.0);
-/// assert_eq!(result, None);
-/// ```
-#[inline]
-#[unstable(feature = "cmp_partial")]
-#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")]
-pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
-    match v1.partial_cmp(&v2) {
-        Some(Equal) | Some(Less) => Some(v2),
-        Some(Greater) => Some(v1),
-        None => None
-    }
-}
-
 // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
 mod impls {
     use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering};