1.19.0[−][src]Struct sp_std::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.
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]
T: Clone,
impl<T> Copy for Reverse<T> where
T: Copy,
[src]
T: Copy,
impl<T> Debug for Reverse<T> where
T: Debug,
[src]
T: Debug,
impl<T> Default for Reverse<T> where
T: Default,
[src]
T: Default,
impl<T> Eq for Reverse<T> where
T: Eq,
[src]
T: Eq,
impl<T> Hash for Reverse<T> where
T: Hash,
[src]
T: Hash,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Ord for Reverse<T> where
T: Ord,
[src]
T: Ord,
pub fn cmp(&self, other: &Reverse<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T> PartialEq<Reverse<T>> for Reverse<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
impl<T> PartialOrd<Reverse<T>> for Reverse<T> where
T: PartialOrd<T>,
[src]
T: PartialOrd<T>,
pub fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Reverse<T>) -> bool
[src]
pub fn le(&self, other: &Reverse<T>) -> bool
[src]
pub fn gt(&self, other: &Reverse<T>) -> bool
[src]
pub fn ge(&self, other: &Reverse<T>) -> bool
[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]
T: RefUnwindSafe,
impl<T> Send for Reverse<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Reverse<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Reverse<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Reverse<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[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.
pub 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]
U: TryFrom<T>,