1.19.0[][src]Struct core::cmp::Reverse

pub struct Reverse<T>(pub T);

A helper struct for reverse ordering.

This struct is a helper to be used with functions like Vec::sort_by_key and can be used to reverse order a part of a key.

Example usage:

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]);Run

Trait Implementations

impl<T: Copy> Copy for Reverse<T>
[src]

impl<T: PartialEq> PartialEq<Reverse<T>> for Reverse<T>
[src]

impl<T: Eq> Eq for Reverse<T>
[src]

impl<T: Ord> Ord for Reverse<T>
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<T: PartialOrd> PartialOrd<Reverse<T>> for Reverse<T>
[src]

impl<T: Clone> Clone for Reverse<T>
[src]

Performs copy-assignment from source. Read more

impl<T: Default> Default for Reverse<T>
[src]

impl<T: Hash> Hash for Reverse<T>
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Debug> Debug for Reverse<T>
[src]

Auto Trait Implementations

impl<T> Send for Reverse<T> where
    T: Send

impl<T> Sync for Reverse<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from #33417)

The type returned in the event of a conversion error.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from #33417)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]