rust/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs
2013-03-29 16:39:08 -07:00

22 lines
345 B
Rust

trait Reverser {
fn reverse(&self);
}
impl<'self> Reverser for &'self mut [uint] {
fn reverse(&self) {
vec::reverse(*self);
}
}
fn bar(v: &mut [uint]) {
v.reverse();
v.reverse();
v.reverse();
}
pub fn main() {
let mut the_vec = ~[1, 2, 3, 100];
bar(the_vec);
assert!(the_vec == ~[100, 3, 2, 1]);
}