diff --git a/src/custom_ord_wrapper.rs b/src/custom_ord_wrapper.rs
index 3a7835c..2e92406 100644
--- a/src/custom_ord_wrapper.rs
+++ b/src/custom_ord_wrapper.rs
@@ -19,10 +19,6 @@ along with range_bounds_map. If not, see .
use std::cmp::Ordering;
-pub trait CustomOrd {
- fn cmp(&self, a: &T) -> Ordering;
-}
-
pub enum CustomOrdWrapper {
CustomOrd(C),
Value(T),
@@ -30,18 +26,18 @@ pub enum CustomOrdWrapper {
impl Ord for CustomOrdWrapper
where
- C: CustomOrd,
+ C: Fn(&T) -> Ordering,
{
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(
CustomOrdWrapper::CustomOrd(custom_ord),
CustomOrdWrapper::Value(value),
- ) => custom_ord.cmp(value),
+ ) => custom_ord(value),
(
CustomOrdWrapper::Value(value),
CustomOrdWrapper::CustomOrd(custom_ord),
- ) => custom_ord.cmp(value),
+ ) => custom_ord(value),
_ => panic!(
"You must have exactly ONE Value and ONE CustomOrd when comparing CustomOrdWrapper's"
),
@@ -51,18 +47,18 @@ where
impl PartialOrd for CustomOrdWrapper
where
- C: CustomOrd,
+ C: Fn(&T) -> Ordering,
{
fn partial_cmp(&self, other: &Self) -> Option {
Some(self.cmp(other))
}
}
-impl Eq for CustomOrdWrapper where C: CustomOrd {}
+impl Eq for CustomOrdWrapper where C: Fn(&T) -> Ordering {}
impl PartialEq for CustomOrdWrapper
where
- C: CustomOrd,
+ C: Fn(&T) -> Ordering,
{
fn eq(&self, other: &Self) -> bool {
self.cmp(other).is_eq()