[][src]Struct cmp_wrap::permissive::KeyCmpContext

pub struct KeyCmpContext<KF> { /* fields omitted */ }

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]

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

impl<KF> Send for KeyCmpContext<KF> where
    KF: Send

impl<KF> Sync for KeyCmpContext<KF> where
    KF: Sync

impl<KF> Unpin for KeyCmpContext<KF> where
    KF: Unpin

impl<KF> UnwindSafe for KeyCmpContext<KF> where
    KF: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.