2013-01-22 17:20:08 -08:00
|
|
|
trait Reverser {
|
2013-03-15 15:24:24 -04:00
|
|
|
fn reverse(self);
|
2013-01-22 17:20:08 -08:00
|
|
|
}
|
|
|
|
|
2013-03-25 13:21:04 -07:00
|
|
|
impl<'self> Reverser for &'self mut [uint] {
|
2013-03-15 15:24:24 -04:00
|
|
|
fn reverse(self) {
|
|
|
|
vec::reverse(self);
|
2013-01-22 17:20:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-29 21:30:22 -05:00
|
|
|
fn bar(v: &mut [uint]) {
|
2013-01-22 17:20:08 -08:00
|
|
|
v.reverse();
|
|
|
|
v.reverse();
|
|
|
|
v.reverse();
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2013-01-22 17:20:08 -08:00
|
|
|
let mut the_vec = ~[1, 2, 3, 100];
|
|
|
|
bar(the_vec);
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(the_vec, ~[100, 3, 2, 1]);
|
2013-01-22 17:20:08 -08:00
|
|
|
}
|