rust/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs

16 lines
347 B
Rust
Raw Normal View History

2014-02-05 16:33:10 -06:00
// http://rust-lang.org/COPYRIGHT.
#![feature(slice_patterns)]
fn main() {
2015-01-31 10:23:42 -06:00
let mut a = [1, 2, 3, 4];
2013-03-15 14:24:24 -05:00
let t = match a {
[1, 2, ref tail..] => tail,
_ => unreachable!()
};
println!("t[0]: {}", t[0]);
a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed
println!("t[0]: {}", t[0]);
2013-03-15 14:24:24 -05:00
t[0];
}