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