[−][src]Struct cmp_wrap::permissive::KeyCmpContext
Used to easily wrap multiple values with the same key function.
Methods
impl<KF> KeyCmpContext<KF>
[src]
pub fn new<T, K>(key_func: KF) -> KeyCmpContext<KF> where
KF: Fn(&T) -> K,
[src]
KF: Fn(&T) -> K,
Creates new key context which lets you easily wrap values with the same key function (same context).
pub fn wrap<T>(&self, value: T) -> CmpByKey<KF, T>
[src]
This is how you wrap values in the same context context.
use cmp_wrap::permissive::KeyCmpContext; let by_length = KeyCmpContext::new(|v: &Vec<_>| v.len()); let long_vec = by_length.wrap(vec![1,2,3,4]); let short_vec = by_length.wrap(vec![1,2]); assert!(long_vec > short_vec, "The vec {:?} is longer then {:?}", long_vec, short_vec);
Auto Trait Implementations
impl<KF> RefUnwindSafe for KeyCmpContext<KF> where
KF: RefUnwindSafe,
KF: RefUnwindSafe,
impl<KF> Send for KeyCmpContext<KF> where
KF: Send,
KF: Send,
impl<KF> Sync for KeyCmpContext<KF> where
KF: Sync,
KF: Sync,
impl<KF> Unpin for KeyCmpContext<KF> where
KF: Unpin,
KF: Unpin,
impl<KF> UnwindSafe for KeyCmpContext<KF> where
KF: UnwindSafe,
KF: 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,
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, 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(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>,