Skip to content

Commit

Permalink
feat: impl Borrow for OrderedFloat<f32> and OrderedFloat<f64>
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Sep 25, 2024
1 parent c8422ce commit 299b466
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ fn canonicalize_signed_zero<T: FloatCore>(x: T) -> T {
#[repr(transparent)]
pub struct OrderedFloat<T>(pub T);

impl Borrow<f32> for OrderedFloat<f32> {
#[inline]
fn borrow(&self) -> &f32 {
&self.0
}
}

impl Borrow<f64> for OrderedFloat<f64> {
#[inline]
fn borrow(&self) -> &f64 {
&self.0
}
}

#[cfg(feature = "num-cmp")]
mod impl_num_cmp {
use super::OrderedFloat;
Expand Down

0 comments on commit 299b466

Please sign in to comment.