rust/src/test/run-pass/impl-variance.rs

17 lines
262 B
Rust
Raw Normal View History

trait foo {
fn foo() -> uint;
}
2012-08-07 18:10:06 -07:00
impl<T> ~[const T]: foo {
fn foo() -> uint { vec::len(self) }
}
fn main() {
let v = ~[const 0];
assert v.foo() == 1u;
let v = ~[0];
assert v.foo() == 1u;
let v = ~[mut 0];
assert v.foo() == 1u;
}