rust/src/test/run-pass/static-methods-in-traits2.rs

19 lines
363 B
Rust

pub trait Number: NumConv {
static pure fn from<T:Number>(n: T) -> self;
}
pub impl float: Number {
static pure fn from<T:Number>(n: T) -> float { n.to_float() }
}
pub trait NumConv {
pure fn to_float(&self) -> float;
}
pub impl float: NumConv {
pure fn to_float(&self) -> float { *self }
}
fn main() {
let _: float = Number::from(0.0f);
}