Skip to content

Commit

Permalink
Changed cmp::Reverse to unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 28, 2017
1 parent d005d91 commit 7efbb69
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libcore/cmp.rs
Expand Up @@ -330,25 +330,26 @@ 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)]
#[stable(feature = "rust1", since = "1.18.0")]
#[unstable(feature = "reverse_cmp_key", issue = "40720")]
pub struct Reverse<T>(pub T);

#[stable(feature = "rust1", since = "1.18.0")]
#[unstable(feature = "reverse_cmp_key", issue = "40720")]
impl<T: PartialOrd> PartialOrd for Reverse<T> {
#[inline]
fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
other.0.partial_cmp(&self.0)
}
}

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

0 comments on commit 7efbb69

Please sign in to comment.