Navigation Menu

Skip to content

Commit

Permalink
Stabilize cmp::Reverse
Browse files Browse the repository at this point in the history
Closes #40893
  • Loading branch information
sfackler committed Jun 25, 2017
1 parent 14c2f99 commit 05cbdb1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libcore/cmp.rs
Expand Up @@ -335,18 +335,17 @@ impl Ordering {
/// Example usage:
///
/// ```
/// #![feature(reverse_cmp_key)]
/// use std::cmp::Reverse;
///
/// let mut v = vec![1, 2, 3, 4, 5, 6];
/// v.sort_by_key(|&num| (num > 3, Reverse(num)));
/// assert_eq!(v, vec![3, 2, 1, 6, 5, 4]);
/// ```
#[derive(PartialEq, Eq, Debug)]
#[unstable(feature = "reverse_cmp_key", issue = "40893")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
pub struct Reverse<T>(pub T);

#[unstable(feature = "reverse_cmp_key", issue = "40893")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: PartialOrd> PartialOrd for Reverse<T> {
#[inline]
fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
Expand All @@ -363,7 +362,7 @@ impl<T: PartialOrd> PartialOrd for Reverse<T> {
fn gt(&self, other: &Self) -> bool { other.0 > self.0 }
}

#[unstable(feature = "reverse_cmp_key", issue = "40893")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: Ord> Ord for Reverse<T> {
#[inline]
fn cmp(&self, other: &Reverse<T>) -> Ordering {
Expand Down

0 comments on commit 05cbdb1

Please sign in to comment.