[][src]Struct cmp_wrap::permissive::CmpByKey

pub struct CmpByKey<'kf, KF, T> { /* fields omitted */ }

The main structure of this crate. Lets you define a "key function" over any structure, which will change the way the value is being compared. Very useful when you need to enter your data to different data structures (such as max heaps, sorted trees and so on), with different comparision criteria.

Methods

impl<'kf, KF, T> CmpByKey<'kf, KF, T>[src]

pub fn new<'rkf>(value: T, key_func: &'rkf KF) -> Self where
    'rkf: 'kf, 
[src]

Let you wrap a value with a key function which defines the way to compare it to other values.

Example

use cmp_wrap::permissive::CmpByKey;
let x = CmpByKey::new(32, &|x: &i32| -> i32 { -*x });

pub fn remove_wrapper(self) -> T[src]

Lets you get the original value which the wrapper wrappes, destroys the wrapper.

Example

use cmp_wrap::permissive::CmpByKey;
let v: i32 = 32;

fn is_type_i32(x: i32) {};

let x = CmpByKey::new(v, &|x: &i32| -> i32 { -*x });
let v_again = x.remove_wrapper();

is_type_i32(v_again);

Trait Implementations

impl<'_, T: Debug, KF> Debug for CmpByKey<'_, KF, T>[src]

impl<'_, T, K: Eq, KF> Eq for CmpByKey<'_, KF, T> where
    KF: Fn(&T) -> K, 
[src]

impl<'_, T, K: Ord, KF> Ord for CmpByKey<'_, KF, T> where
    KF: Fn(&T) -> K, 
[src]

impl<'_, '_, T, K, KF, OT, OKF, OK> PartialEq<CmpByKey<'_, OKF, OT>> for CmpByKey<'_, KF, T> where
    K: PartialEq<OK>,
    KF: Fn(&T) -> K,
    OKF: Fn(&OT) -> OK, 
[src]

impl<'_, '_, T, K, KF, OT, OKF, OK> PartialOrd<CmpByKey<'_, OKF, OT>> for CmpByKey<'_, KF, T> where
    K: PartialOrd<OK>,
    KF: Fn(&T) -> K,
    OKF: Fn(&OT) -> OK, 
[src]

Auto Trait Implementations

impl<'kf, KF, T> RefUnwindSafe for CmpByKey<'kf, KF, T> where
    KF: RefUnwindSafe,
    T: RefUnwindSafe

impl<'kf, KF, T> Send for CmpByKey<'kf, KF, T> where
    KF: Sync,
    T: Send

impl<'kf, KF, T> Sync for CmpByKey<'kf, KF, T> where
    KF: Sync,
    T: Sync

impl<'kf, KF, T> Unpin for CmpByKey<'kf, KF, T> where
    T: Unpin

impl<'kf, KF, T> UnwindSafe for CmpByKey<'kf, KF, T> where
    KF: RefUnwindSafe,
    T: 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.