2013-01-22 19:20:08 -06:00
|
|
|
trait Reverser {
|
|
|
|
fn reverse(&self);
|
|
|
|
}
|
|
|
|
|
2013-01-29 20:30:22 -06:00
|
|
|
impl &mut [uint] : Reverser {
|
2013-01-22 19:20:08 -06:00
|
|
|
fn reverse(&self) {
|
|
|
|
vec::reverse(*self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-29 20:30:22 -06:00
|
|
|
fn bar(v: &mut [uint]) {
|
2013-01-22 19:20:08 -06:00
|
|
|
v.reverse();
|
|
|
|
v.reverse();
|
|
|
|
v.reverse();
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2013-01-22 19:20:08 -06:00
|
|
|
let mut the_vec = ~[1, 2, 3, 100];
|
|
|
|
bar(the_vec);
|
|
|
|
assert the_vec == ~[100, 3, 2, 1];
|
|
|
|
}
|