1.19.0[][src]Struct sp_std::prelude::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.

Examples

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

Trait Implementations

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

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

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

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

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

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

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

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

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

impl<T> StructuralEq for Reverse<T>[src]

impl<T> StructuralPartialEq for Reverse<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Reverse<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Reverse<T> where
    T: Send
[src]

impl<T> Sync for Reverse<T> where
    T: Sync
[src]

impl<T> Unpin for Reverse<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Reverse<T> where
    T: UnwindSafe
[src]

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.