From a43c630ee9c0a069dc9fabaeb138a3550900f19a Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 12 Dec 2012 13:24:38 +1000 Subject: [PATCH] Make from_float accept a generic Float argument --- src/num/types.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/num/types.rs b/src/num/types.rs index c2e36bd..4cb7d28 100644 --- a/src/num/types.rs +++ b/src/num/types.rs @@ -284,7 +284,7 @@ pub impl int: Integer {} pub trait Float: Number FuzzyEq { - static pure fn from_float(n: float) -> self; + static pure fn from_float(n: T) -> self; static pure fn NaN() -> self; static pure fn infinity() -> self; @@ -314,7 +314,7 @@ pub trait Float: Number FuzzyEq { } pub impl f32: Float { - #[inline(always)] static pure fn from_float(n: float) -> f32 { n as f32 } + #[inline(always)] static pure fn from_float(n: T) -> f32 { n.to_f32() } #[inline(always)] static pure fn NaN() -> f32 { 0_f32 / 0_f32 } #[inline(always)] static pure fn infinity() -> f32 { 1_f32 / 0_f32 } @@ -344,7 +344,7 @@ pub impl f32: Float { } pub impl f64: Float { - #[inline(always)] static pure fn from_float(n: float) -> f64 { n as f64 } + #[inline(always)] static pure fn from_float(n: T) -> f64 { n.to_f64() } #[inline(always)] static pure fn NaN() -> f64 { 0_f64 / 0_f64 } #[inline(always)] static pure fn infinity() -> f64 { 1_f64 / 0_f64 } @@ -374,7 +374,7 @@ pub impl f64: Float { } pub impl float: Float { - #[inline(always)] static pure fn from_float(n: float) -> float { n } + #[inline(always)] static pure fn from_float(n: T) -> float { n.to_float() } #[inline(always)] static pure fn NaN() -> float { 0_f / 0_f } #[inline(always)] static pure fn infinity() -> float { 1_f / 0_f }