Error code E0384

An immutable variable was reassigned.

Erroneous code example:

fn main() {
    let x = 3;
    x = 5; // error, reassignment of immutable variable
}
Run

By default, variables in Rust are immutable. To fix this error, add the keyword mut after the keyword let when declaring the variable. For example:

fn main() {
    let mut x = 3;
    x = 5;
}
Run

Back to list of error codes