Struct creusot_contracts::std::cmp::Reverse
1.19.0 · source · #[repr(transparent)]pub struct Reverse<T>(pub T);
Expand description
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]);
Tuple Fields§
§0: T
Trait Implementations§
source§impl<T: DeepModel> DeepModel for Reverse<T>
impl<T: DeepModel> DeepModel for Reverse<T>
source§fn deep_model(self) -> Self::DeepModelTy
fn deep_model(self) -> Self::DeepModelTy
logic
pearlite! { Reverse(self.0.deep_model()) }
type DeepModelTy = Reverse<<T as DeepModel>::DeepModelTy>
1.19.0 · source§impl<T> Ord for Reverse<T>where
T: Ord,
impl<T> Ord for Reverse<T>where
T: Ord,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: OrdLogic> OrdLogic for Reverse<T>
impl<T: OrdLogic> OrdLogic for Reverse<T>
source§fn cmp_log(self, o: Self) -> Ordering
fn cmp_log(self, o: Self) -> Ordering
logic
match self.0.cmp_log(o.0) { Ordering::Equal => Ordering::Equal, Ordering::Less => Ordering::Greater, Ordering::Greater => Ordering::Less, }
source§fn cmp_le_log(x: Self, y: Self)
fn cmp_le_log(x: Self, y: Self)
law
ensures
x.le_log(y) == (x.cmp_log(y) != Ordering::Greater)
source§fn cmp_lt_log(x: Self, y: Self)
fn cmp_lt_log(x: Self, y: Self)
law
ensures
x.lt_log(y) == (x.cmp_log(y) == Ordering::Less)
source§fn cmp_ge_log(x: Self, y: Self)
fn cmp_ge_log(x: Self, y: Self)
law
ensures
x.ge_log(y) == (x.cmp_log(y) != Ordering::Less)
source§fn cmp_gt_log(x: Self, y: Self)
fn cmp_gt_log(x: Self, y: Self)
law
ensures
x.gt_log(y) == (x.cmp_log(y) == Ordering::Greater)
source§fn trans(x: Self, y: Self, z: Self, o: Ordering)
fn trans(x: Self, y: Self, z: Self, o: Ordering)
law
requires
x.cmp_log(y) == o
requires
y.cmp_log(z) == o
ensures
x.cmp_log(z) == o
source§fn antisym1(x: Self, y: Self)
fn antisym1(x: Self, y: Self)
law
requires
x.cmp_log(y) == Ordering::Less
ensures
y.cmp_log(x) == Ordering::Greater
1.19.0 · source§impl<T> PartialEq for Reverse<T>where
T: PartialEq,
impl<T> PartialEq for Reverse<T>where
T: PartialEq,
1.19.0 · source§impl<T> PartialOrd for Reverse<T>where
T: PartialOrd,
impl<T> PartialOrd for Reverse<T>where
T: PartialOrd,
source§fn le(&self, other: &Reverse<T>) -> bool
fn le(&self, other: &Reverse<T>) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T> Copy for Reverse<T>where
T: Copy,
impl<T> Eq for Reverse<T>where
T: Eq,
impl<T> StructuralPartialEq for Reverse<T>
Auto Trait Implementations§
impl<T> !Freeze for Reverse<T>
impl<T> !RefUnwindSafe for Reverse<T>
impl<T> !Send for Reverse<T>
impl<T> !Sync for Reverse<T>
impl<T> !Unpin for Reverse<T>
impl<T> !UnwindSafe for Reverse<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> MakeSized for Twhere
T: ?Sized,
impl<T> MakeSized for Twhere
T: ?Sized,
source§fn make_sized(&self) -> Box<T>
fn make_sized(&self) -> Box<T>
logic ⚠
ensures
*result == *self