I'm new to Rust, and I'm having trouble with the concept of references and ownership. I want to simply reassign an array but I'm running into errors. I'm tried the following:
fn change(a: &mut [i64; 3]) {
a = [5, 4, 1];
}
but I'm getting the following error:
--> main.rs:6:7
|
6 | a = [5, 4, 1];
| ^^^^^^^^^
| |
| expected mutable reference, found array of 3 elements
| help: consider mutably borrowing here: `&mut [5, 4, 1]`
|
= note: expected type `&mut [i64; 3]`
I tried adding the &mut to the array, but I get a completely new error. Can someone point me in the right direction?