Hello there !
I’m reading borrowing chapter from the rust book.
In the previous example it is explained that passing a “simple” reference to a vector do not allow the function to mute it.
So, in the next section, mutables references are introduced, so I’m trying to apply this concept with the same example.
Here is my code:
fn take_ownership(v1: &mut Vec<i32>){
v1.push(42);
}
fn main() {
let mut v1 = vec![1, 2, 3];
take_ownership(&mut v1);
}
But when I’m trying to compile this, I get this error:
Compiling hello_world v0.1.0 (/home/matthieu/Config/settings/Projets/Rust/hello_world)
Running `rustc --crate-name hello_world src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=62e4bdd6224c686e -C extra-filename=-62e4bdd6224c686e --out-dir /home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/deps -C incremental=/home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/incremental -L dependency=/home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/deps`
error: Could not compile `hello_world`.
Caused by:
process didn't exit successfully: `rustc --crate-name hello_world src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=62e4bdd6224c686e -C extra-filename=-62e4bdd6224c686e --out-dir /home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/deps -C incremental=/home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/incremental -L dependency=/home/matthieu/Config/settings/Projets/Rust/hello_world/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)
What I am doing wrong ?