std: Replace num::IntConvertible with {To,From}Primitive
This commit is contained in:
parent
17548378a7
commit
d9d1dfc195
14 changed files with 580 additions and 321 deletions
|
|
@ -36,6 +36,6 @@ pub fn main() {
|
|||
|
||||
// floats
|
||||
// num
|
||||
assert_eq!(10f32.to_int(), 10);
|
||||
assert_eq!(10f64.to_int(), 10);
|
||||
assert_eq!(10f32.to_int().unwrap(), 10);
|
||||
assert_eq!(10f64.to_int().unwrap(), 10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub trait NumExt: Num + NumCast + Eq + Ord {}
|
|||
|
||||
pub trait FloatExt: NumExt + ApproxEq<Self> {}
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > NumCast::from(1) }
|
||||
fn greater_than_one_float<T:FloatExt>(n: &T) -> bool { *n > NumCast::from(1) }
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > NumCast::from(1).unwrap() }
|
||||
fn greater_than_one_float<T:FloatExt>(n: &T) -> bool { *n > NumCast::from(1).unwrap() }
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ trait Num {
|
|||
pub trait NumExt: Num + NumCast { }
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool {
|
||||
n.gt(&NumCast::from(1))
|
||||
n.gt(&NumCast::from(1).unwrap())
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use std::num::NumCast;
|
|||
pub trait NumExt: Num + NumCast + Ord { }
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool {
|
||||
*n > NumCast::from(1)
|
||||
*n > NumCast::from(1).unwrap()
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub trait NumExt: Eq + Ord + Num + NumCast {}
|
|||
impl NumExt for f32 {}
|
||||
|
||||
fn num_eq_one<T:NumExt>(n: T) {
|
||||
println!("{}", n == NumCast::from(1))
|
||||
println!("{}", n == NumCast::from(1).unwrap())
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ impl NumExt for f32 {}
|
|||
impl NumExt for int {}
|
||||
|
||||
fn num_eq_one<T:NumExt>() -> T {
|
||||
NumCast::from(1)
|
||||
NumCast::from(1).unwrap()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue