Created
July 17, 2012 00:56
-
-
Save eholk/3126225 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 bar<T> { | |
fn get_bar() -> T; | |
} | |
fn foo<T, U: bar<T>>(b: U) -> T { | |
b.get_bar() | |
} | |
class cbar : bar<int> { | |
let x: int; | |
new(x: int) { self.x = x; } | |
fn get_bar() -> int { | |
self.x | |
} | |
} | |
fn main() { | |
let x: int = foo(cbar(5)); | |
assert x == 5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this compile error: