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