mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
13 lines
318 B
Rust
13 lines
318 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 mutable reference `&mut [_]`
|
|
//~| found reference `&[isize]`
|
|
//~| types differ in mutability
|
|
}
|