Make from_float accept a generic Float argument
This commit is contained in:
parent
5aef15d9d7
commit
a43c630ee9
1 changed files with 4 additions and 4 deletions
|
@ -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<T: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<T: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<T: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<T: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 }
|
||||
|
|
Loading…
Reference in a new issue