rust/src/test/run-pass/auto-ref-sliceable.rs

16 lines
259 B
Rust
Raw Normal View History

trait Pushable<T> {
fn push_val(&mut self, +t: T);
}
impl<T> ~[T]: Pushable<T> {
fn push_val(&mut self, +t: T) {
2012-09-19 00:45:24 -05:00
self.push(move t);
}
}
fn main() {
let mut v = ~[1];
v.push_val(2);
v.push_val(3);
assert v == ~[1, 2, 3];
}