PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/generic-derived-type.rs

http://github.com/jruderman/rust
Rust | 18 lines | 13 code | 5 blank | 0 comment | 2 complexity | c8efbc05a846b8d41033ce1d5de6d520 MD5 | raw file
 1
 2
 3fn g<X: copy>(x: X) -> X { return x; }
 4
 5fn f<T: copy>(t: T) -> {a: T, b: T} {
 6    type pair = {a: T, b: T};
 7
 8    let x: pair = {a: t, b: t};
 9    return g::<pair>(x);
10}
11
12fn main() {
13    let b = f::<int>(10);
14    log(debug, b.a);
15    log(debug, b.b);
16    assert (b.a == 10);
17    assert (b.b == 10);
18}