pub struct Extract<E, C> { /* private fields */ }Expand description
A comparator that extracts a sort key from a value.
§Examples
use compare::{Compare, Extract};
use std::cmp::Ordering::Greater;
let a = [1, 2, 3];
let b = [4, 5];
let cmp = Extract::new(|s: &[i32]| s.len());
assert_eq!(cmp.compare(&a, &b), Greater);Implementations§
Trait Implementations§
Source§impl<E, C, T: ?Sized, K> Compare<T> for Extract<E, C>
impl<E, C, T: ?Sized, K> Compare<T> for Extract<E, C>
Source§fn compare(&self, l: &T, r: &T) -> Ordering
fn compare(&self, l: &T, r: &T) -> Ordering
Compares two values, returning
Less, Equal, or Greater if l is less
than, equal to, or greater than r, respectively.Source§fn borrowing(self) -> Borrowing<Self, L, R>where
Self: Sized,
fn borrowing(self) -> Borrowing<Self, L, R>where
Self: Sized,
Borrows the comparator’s parameters before comparing them. Read more
Source§fn rev(self) -> Rev<Self>where
Self: Sized,
fn rev(self) -> Rev<Self>where
Self: Sized,
Reverses the ordering of the comparator. Read more
impl<E: Copy, C: Copy> Copy for Extract<E, C>
impl<E: Eq, C: Eq> Eq for Extract<E, C>
impl<E, C> StructuralPartialEq for Extract<E, C>
Auto Trait Implementations§
impl<E, C> Freeze for Extract<E, C>
impl<E, C> RefUnwindSafe for Extract<E, C>where
E: RefUnwindSafe,
C: RefUnwindSafe,
impl<E, C> Send for Extract<E, C>
impl<E, C> Sync for Extract<E, C>
impl<E, C> Unpin for Extract<E, C>
impl<E, C> UnwindSafe for Extract<E, C>where
E: UnwindSafe,
C: UnwindSafe,
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