rust/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs
Niko Matsakis 2b67d88809 Rewrite the coercion code to be more readable, more sound, and to reborrow when
needed.

Regarding soundness: there was a subtle bug in how it was done before; see the
compile-fail test for an example.

Regarding reborrowing: reborrowing allows mut and const
slices/borrowed-pointers to be used with pure fns that expect immutable data.

r=brson
2013-01-28 10:01:59 -08:00

16 lines
244 B
Rust

trait Reverser {
fn reverse(&self);
}
fn bar(v: &[mut uint]) {
vec::reverse(v);
vec::reverse(v);
vec::reverse(v);
}
fn main() {
let mut the_vec = ~[1, 2, 3, 100];
bar(the_vec);
assert the_vec == ~[100, 3, 2, 1];
}