2012-07-11 15:00:40 -07:00
|
|
|
trait foo {
|
|
|
|
fn foo() -> uint;
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:10:06 -07:00
|
|
|
impl<T> ~[const T]: foo {
|
2012-03-16 16:49:11 -07:00
|
|
|
fn foo() -> uint { vec::len(self) }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-06-29 16:26:56 -07:00
|
|
|
let v = ~[const 0];
|
2012-03-16 16:49:11 -07:00
|
|
|
assert v.foo() == 1u;
|
2012-06-29 16:26:56 -07:00
|
|
|
let v = ~[0];
|
2012-03-16 16:49:11 -07:00
|
|
|
assert v.foo() == 1u;
|
2012-06-29 16:26:56 -07:00
|
|
|
let v = ~[mut 0];
|
2012-03-16 16:49:11 -07:00
|
|
|
assert v.foo() == 1u;
|
2012-07-11 15:00:40 -07:00
|
|
|
}
|