rust/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs

22 lines
343 B
Rust
Raw Normal View History

trait Reverser {
2013-03-15 14:24:24 -05:00
fn reverse(self);
}
impl<'self> Reverser for &'self mut [uint] {
2013-03-15 14:24:24 -05:00
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_eq!(the_vec, ~[100, 3, 2, 1]);
}