PageRenderTime 18ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/newtype-polymorphic.rs

http://github.com/jruderman/rust
Rust | 12 lines | 9 code | 3 blank | 0 comment | 3 complexity | 2ff674db7a1ed5c2c6f253ff30e7aacb MD5 | raw file
 1enum myvec<X> = ~[X];
 2
 3fn myvec_deref<X: copy>(mv: myvec<X>) -> ~[X] { return *mv; }
 4
 5fn myvec_elt<X: copy>(mv: myvec<X>) -> X { return mv[0]; }
 6
 7fn main() {
 8    let mv = myvec(~[1, 2, 3]);
 9    assert (myvec_deref(mv)[1] == 2);
10    assert (myvec_elt(mv) == 1);
11    assert (mv[2] == 3);
12}