Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Expand from_float macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 26, 2023
1 parent 1e2a89c commit 22116b6
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,22 +517,22 @@ macro_rules! from_unsigned {
};
}

macro_rules! from_float {
($($float_ty:ident)*) => {
$(
impl From<$float_ty> for Number {
#[inline]
fn from(f: $float_ty) -> Self {
Number { n: N::Float(f as f64) }
}
}
)*
from_signed!(i8 i16 i32 i64 isize);
from_unsigned!(u8 u16 u32 u64 usize);

impl From<f32> for Number {
fn from(f: f32) -> Self {
Number {
n: N::Float(f as f64),
}
}
}

from_signed!(i8 i16 i32 i64 isize);
from_unsigned!(u8 u16 u32 u64 usize);
from_float!(f32 f64);
impl From<f64> for Number {
fn from(f: f64) -> Self {
Number { n: N::Float(f) }
}
}

// This is fine, because we don't _really_ implement hash for floats
// all other hash functions should work as expected
Expand Down

0 comments on commit 22116b6

Please sign in to comment.