Created
July 2, 2012 19:01
-
-
Save msullivan/3034982 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
iface builder<A> { | |
// This would have some methods | |
} | |
impl extensions<A: copy> of builder<A> for @[A] { } | |
// Pretend that these are static typeclass methods | |
fn new_container<A,IA:builder<A>>() -> IA { | |
fail "this is a dummy for type inference testing!" | |
} | |
fn push<A,IA:builder<A>>(&_v: IA, +_x: A) { | |
fail "this is a dummy for type inference testing!" | |
} | |
fn build_from_vec<A:copy,IA:builder<A>>(v: &[A]) -> IA { | |
let mut new_v = new_container(); | |
for v.each() |x| { | |
push(new_v, x); | |
} | |
ret new_v; | |
} | |
fn main() { | |
let x: @[int] = build_from_vec([1,2,3]/_); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment