1.19.0[−][src]Struct core::cmp::Reverse
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]
fn cmp(&self, other: &Reverse<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self where
Self: Sized,
1.21.0[src]
Self: Sized,
fn min(self, other: Self) -> Self where
Self: Sized,
1.21.0[src]
Self: Sized,
fn clamp(self, min: Self, max: Self) -> Self where
Self: Sized,
[src]
Self: Sized,
impl<T: PartialOrd> PartialOrd<Reverse<T>> for Reverse<T>
[src]
fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
impl<T: Clone> Clone for Reverse<T>
[src]
fn clone(&self) -> Reverse<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Default> Default for Reverse<T>
[src]
impl<T: Hash> Hash for Reverse<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where
Self: Sized,
1.3.0[src]
Self: Sized,
impl<T: Debug> Debug for Reverse<T>
[src]
Auto Trait Implementations
impl<T> Send for Reverse<T> where
T: Send,
T: Send,
impl<T> Sync for Reverse<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Reverse<T> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut Self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,