cmp_wrap
Have you ever needed to compare the same data by different fields, depending on context? If so, this crate is for you!
The main feature of this crate is a lightweight wrapper around types which lets you compare them after a mappeing (keying) function, meaning the parital_cmp operators ( < , > , == ...) are applied on the result of the keying function.
There are two main modules in this crate: [permissive] and [strict]. The permissive lets you compare different types as long as the keying function returns comparable types.
The strict implementation woun't let you compare different types, and will save you from comparing by two different contexts.
Examples
Using context
You probably have some kind of context in which you would like to compare your values, such as length of vectors or the first value.
use KeyCmpContext;
let by_length = new;
let long_vec = by_length.wrap;
let short_vec = by_length.wrap;
assert!;
By direct creation
you can define the key function on a "case by case" basis.
use CmpByKey;
let len_as_key = ;
let long_vec = new;
let short_vec = new;
assert!;
License: MIT