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.
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]);
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]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
[src]1.3.0
impl<T> Ord for Reverse<T> where
T: Ord,
[src]
fn cmp(&self, other: &Reverse<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
[src]1.21.0
fn min(self, other: Self) -> Self
[src]1.21.0
fn clamp(self, min: Self, max: Self) -> Self
[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]
fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Reverse<T>) -> bool
[src]
fn le(&self, other: &Reverse<T>) -> bool
[src]
fn gt(&self, other: &Reverse<T>) -> bool
[src]
fn ge(&self, other: &Reverse<T>) -> bool
[src]
impl<T> StructuralEq for Reverse<T>
[src]
impl<T> StructuralPartialEq for Reverse<T>
[src]
impl<T> RefUnwindSafe for Reverse<T> where
T: RefUnwindSafe,
impl<T> Send for Reverse<T> where
T: Send,
impl<T> Sync for Reverse<T> where
T: Sync,
impl<T> Unpin for Reverse<T> where
T: Unpin,
impl<T> UnwindSafe for Reverse<T> where
T: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
fn borrow(&self) -> &TⓘNotable traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized,
type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized,
type Item = <I as Iterator>::Item;
impl<R: Read + ?Sized, '_> Read for &'_ mut R
impl<W: Write + ?Sized, '_> Write for &'_ mut W
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized,
type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized,
type Item = <I as Iterator>::Item;
impl<R: Read + ?Sized, '_> Read for &'_ mut R
impl<W: Write + ?Sized, '_> Write for &'_ mut W
[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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/cmp/struct.Reverse.html