[−][src]Struct cmp_wrap::permissive::CmpByKey
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]
'rkf: 'kf,
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]
KF: Fn(&T) -> K,
impl<'_, T, K: Ord, KF> Ord for CmpByKey<'_, KF, T> where
KF: Fn(&T) -> K,
[src]
KF: Fn(&T) -> K,
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[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]
K: PartialEq<OK>,
KF: Fn(&T) -> K,
OKF: Fn(&OT) -> OK,
fn eq(&self, other: &CmpByKey<OKF, OT>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[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]
K: PartialOrd<OK>,
KF: Fn(&T) -> K,
OKF: Fn(&OT) -> OK,
Auto Trait Implementations
impl<'kf, KF, T> RefUnwindSafe for CmpByKey<'kf, KF, T> where
KF: RefUnwindSafe,
T: RefUnwindSafe,
KF: RefUnwindSafe,
T: RefUnwindSafe,
impl<'kf, KF, T> Send for CmpByKey<'kf, KF, T> where
KF: Sync,
T: Send,
KF: Sync,
T: Send,
impl<'kf, KF, T> Sync for CmpByKey<'kf, KF, T> where
KF: Sync,
T: Sync,
KF: Sync,
T: Sync,
impl<'kf, KF, T> Unpin for CmpByKey<'kf, KF, T> where
T: Unpin,
T: Unpin,
impl<'kf, KF, T> UnwindSafe for CmpByKey<'kf, KF, T> where
KF: RefUnwindSafe,
T: UnwindSafe,
KF: RefUnwindSafe,
T: 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>,