Add documentation comments to Number trait and impls
This commit is contained in:
parent
0c47707436
commit
d4c7abab84
1 changed files with 70 additions and 28 deletions
|
@ -6,101 +6,143 @@ use num::default_eq::DefaultEq;
|
|||
|
||||
|
||||
pub trait Number: DefaultEq, Eq, Num, NumCast, Ord {
|
||||
/**
|
||||
* Construct a number from the type `T:Number`
|
||||
*/
|
||||
static pure fn from<T:Number>(n: T) -> self;
|
||||
|
||||
static pure fn zero() -> self;
|
||||
static pure fn one() -> self;
|
||||
static pure fn zero() -> self; /// The additive identity of the number
|
||||
static pure fn one() -> self; // The multiplicative identity of the number
|
||||
}
|
||||
|
||||
pub impl u8: Number {
|
||||
/**
|
||||
* Construct a `u8` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> u8 { n.to_u8() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> u8 { 0u8 }
|
||||
#[inline(always)] static pure fn one() -> u8 { 1u8 }
|
||||
#[inline(always)] static pure fn zero() -> u8 { 0u8 } /// 0u8
|
||||
#[inline(always)] static pure fn one() -> u8 { 1u8 } // 1u8
|
||||
}
|
||||
|
||||
pub impl u16: Number {
|
||||
/**
|
||||
* Construct a `u16` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> u16 { n.to_u16() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> u16 { 0u16 }
|
||||
#[inline(always)] static pure fn one() -> u16 { 1u16 }
|
||||
#[inline(always)] static pure fn zero() -> u16 { 0u16 } /// 0u16
|
||||
#[inline(always)] static pure fn one() -> u16 { 1u16 } // 1u16
|
||||
}
|
||||
|
||||
pub impl u32: Number {
|
||||
/**
|
||||
* Construct a `u32` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> u32 { n.to_u32() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> u32 { 0u32 }
|
||||
#[inline(always)] static pure fn one() -> u32 { 1u32 }
|
||||
#[inline(always)] static pure fn zero() -> u32 { 0u32 } /// 0u32
|
||||
#[inline(always)] static pure fn one() -> u32 { 1u32 } // 1u32
|
||||
}
|
||||
|
||||
pub impl u64: Number {
|
||||
/**
|
||||
* Construct a `u64` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> u64 { n.to_u64() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> u64 { 0u64 }
|
||||
#[inline(always)] static pure fn one() -> u64 { 1u64 }
|
||||
#[inline(always)] static pure fn zero() -> u64 { 0u64 } /// 0u64
|
||||
#[inline(always)] static pure fn one() -> u64 { 1u64 } // 1u64
|
||||
}
|
||||
|
||||
pub impl uint: Number {
|
||||
/**
|
||||
* Construct a `uint` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> uint { n.to_uint() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> uint { 0u }
|
||||
#[inline(always)] static pure fn one() -> uint { 1u }
|
||||
#[inline(always)] static pure fn zero() -> uint { 0u } /// 0u
|
||||
#[inline(always)] static pure fn one() -> uint { 1u } // 1u
|
||||
}
|
||||
|
||||
pub impl i8: Number {
|
||||
/**
|
||||
* Construct an `i8` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> i8 { n.to_i8() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> i8 { 0i8 }
|
||||
#[inline(always)] static pure fn one() -> i8 { 1i8 }
|
||||
#[inline(always)] static pure fn zero() -> i8 { 0i8 } /// 0i8
|
||||
#[inline(always)] static pure fn one() -> i8 { 1i8 } // 1i8
|
||||
}
|
||||
|
||||
pub impl i16: Number {
|
||||
/**
|
||||
* Construct an `i16` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> i16 { n.to_i16() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> i16 { 0i16 }
|
||||
#[inline(always)] static pure fn one() -> i16 { 1i16 }
|
||||
#[inline(always)] static pure fn zero() -> i16 { 0i16 } /// 0i16
|
||||
#[inline(always)] static pure fn one() -> i16 { 1i16 } // 1i16
|
||||
}
|
||||
|
||||
pub impl i32: Number {
|
||||
/**
|
||||
* Construct an `i32` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> i32 { n.to_i32() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> i32 { 0i32 }
|
||||
#[inline(always)] static pure fn one() -> i32 { 1i32 }
|
||||
#[inline(always)] static pure fn zero() -> i32 { 0i32 } /// 0i32
|
||||
#[inline(always)] static pure fn one() -> i32 { 1i32 } // 1i32
|
||||
}
|
||||
|
||||
pub impl i64: Number {
|
||||
/**
|
||||
* Construct an `i64` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> i64 { n.to_i64() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> i64 { 0i64 }
|
||||
#[inline(always)] static pure fn one() -> i64 { 1i64 }
|
||||
#[inline(always)] static pure fn zero() -> i64 { 0i64 } /// 0i64
|
||||
#[inline(always)] static pure fn one() -> i64 { 1i64 } // 1i64
|
||||
}
|
||||
|
||||
pub impl int: Number {
|
||||
/**
|
||||
* Construct an `int` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> int { n.to_int() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> int { 0 }
|
||||
#[inline(always)] static pure fn one() -> int { 1 }
|
||||
#[inline(always)] static pure fn zero() -> int { 0 } /// 0
|
||||
#[inline(always)] static pure fn one() -> int { 1 } // 1
|
||||
}
|
||||
|
||||
pub impl f32: Number {
|
||||
/**
|
||||
* Construct a `f32` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> f32 { n.to_f32() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> f32 { 0f32 }
|
||||
#[inline(always)] static pure fn one() -> f32 { 1f32 }
|
||||
#[inline(always)] static pure fn zero() -> f32 { 0f32 } /// 0f32
|
||||
#[inline(always)] static pure fn one() -> f32 { 1f32 } // 1f32
|
||||
}
|
||||
|
||||
pub impl f64: Number {
|
||||
/**
|
||||
* Construct a `f64` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> f64 { n.to_f64() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> f64 { 0f64 }
|
||||
#[inline(always)] static pure fn one() -> f64 { 1f64 }
|
||||
#[inline(always)] static pure fn zero() -> f64 { 0f64 } /// 0f64
|
||||
#[inline(always)] static pure fn one() -> f64 { 1f64 } // 1f64
|
||||
}
|
||||
|
||||
pub impl float: Number {
|
||||
/**
|
||||
* Construct a `float` from the type `T:Number`
|
||||
*/
|
||||
#[inline(always)] static pure fn from<T:Number>(n: T) -> float { n.to_float() }
|
||||
|
||||
#[inline(always)] static pure fn zero() -> float { 0f }
|
||||
#[inline(always)] static pure fn one() -> float { 1f }
|
||||
#[inline(always)] static pure fn zero() -> float { 0f } /// 0f
|
||||
#[inline(always)] static pure fn one() -> float { 1f } // 1f
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue