Created
November 27, 2012 03:32
-
-
Save brson/4152196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait MyNum { | |
static fn from_int(int) -> self; | |
} | |
pub trait NumExt: MyNum {} | |
fn greater_than_one<T:NumExt>() -> T { from_int(1) } | |
struct S { | |
v: int | |
} | |
impl S: MyNum { | |
static fn from_int(i: int) -> S { | |
S { | |
v: i | |
} | |
} | |
} | |
impl S: NumExt { } | |
fn main() { | |
let v: S = greater_than_one(); | |
assert v.v == 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment