From 299b4668c16744c5ca34aa463fd2003a15e2ce04 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 26 Sep 2024 02:28:02 +0800 Subject: [PATCH] feat: impl Borrow for OrderedFloat and OrderedFloat Signed-off-by: tison --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 930daef..720fe26 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,6 +79,20 @@ fn canonicalize_signed_zero(x: T) -> T { #[repr(transparent)] pub struct OrderedFloat(pub T); +impl Borrow for OrderedFloat { + #[inline] + fn borrow(&self) -> &f32 { + &self.0 + } +} + +impl Borrow for OrderedFloat { + #[inline] + fn borrow(&self) -> &f64 { + &self.0 + } +} + #[cfg(feature = "num-cmp")] mod impl_num_cmp { use super::OrderedFloat;