Error code E0596

This error occurs because you tried to mutably borrow a non-mutable variable.

Erroneous code example:

#![allow(unused)] fn main() { let x = 1; let y = &mut x; // error: cannot borrow mutably }

In here, x isn't mutable, so when we try to mutably borrow it in y, it fails. To fix this error, you need to make x mutable:

#![allow(unused)] fn main() { let mut x = 1; let y = &mut x; // ok! }