2014-09-15 03:48:58 -05:00
|
|
|
// Test mutability and slicing syntax.
|
|
|
|
|
|
|
|
fn main() {
|
2015-01-08 04:54:35 -06:00
|
|
|
let x: &[isize] = &[1, 2, 3, 4, 5];
|
2014-09-15 03:48:58 -05:00
|
|
|
// Can't mutably slice an immutable slice
|
2015-01-08 04:54:35 -06:00
|
|
|
let slice: &mut [isize] = &mut [0, 1];
|
2019-04-22 02:40:08 -05:00
|
|
|
let _ = &mut x[2..4]; //~ERROR cannot borrow `*x` as mutable, as it is behind a `&` reference
|
2014-09-15 03:48:58 -05:00
|
|
|
}
|