2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2012-12-13 00:50:28 +00:00
|
|
|
pub trait Number: NumConv {
|
2013-03-22 18:23:21 +00:00
|
|
|
fn from<T:Number>(n: T) -> Self;
|
2012-12-13 00:50:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 06:26:09 +00:00
|
|
|
impl Number for f64 {
|
|
|
|
fn from<T:Number>(n: T) -> f64 { n.to_float() }
|
2012-12-13 00:50:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait NumConv {
|
2013-09-26 06:26:09 +00:00
|
|
|
fn to_float(&self) -> f64;
|
2012-12-13 00:50:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 06:26:09 +00:00
|
|
|
impl NumConv for f64 {
|
|
|
|
fn to_float(&self) -> f64 { *self }
|
2012-12-13 00:50:28 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-09-26 06:26:09 +00:00
|
|
|
let _: f64 = Number::from(0.0f64);
|
2013-01-31 03:42:06 +00:00
|
|
|
}
|