2012-11-28 14:34:30 -06:00
|
|
|
trait MyEq { }
|
|
|
|
|
|
|
|
trait MyNum {
|
|
|
|
static fn from_int(int) -> self;
|
|
|
|
}
|
|
|
|
|
2012-12-07 17:09:59 -06:00
|
|
|
pub trait NumExt: MyEq MyNum { }
|
2012-11-28 14:34:30 -06:00
|
|
|
|
|
|
|
struct S { v: int }
|
|
|
|
|
|
|
|
impl S: MyEq { }
|
|
|
|
|
|
|
|
impl S: MyNum {
|
|
|
|
static fn from_int(i: int) -> S {
|
|
|
|
S {
|
|
|
|
v: i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S: NumExt { }
|
|
|
|
|
|
|
|
fn greater_than_one<T:NumExt>() -> T { from_int(1) }
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let v: S = greater_than_one();
|
|
|
|
assert v.v == 1;
|
|
|
|
}
|