rust/src/test/ui/slice-mut.rs
2018-12-25 21:08:33 -07:00

13 lines
300 B
Rust

// Test mutability and slicing syntax.
fn main() {
let x: &[isize] = &[1, 2, 3, 4, 5];
// Immutable slices are not mutable.
let y: &mut[_] = &x[2..4];
//~^ ERROR mismatched types
//~| expected type `&mut [_]`
//~| found type `&[isize]`
//~| types differ in mutability
}