Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Immutability is the default in Rust. Trying to modify an immutable variable in Rust leads to a compiler error:

[E0384] Error: cannot assign twice to immutable variable `x`
   ╭─[ command_2:1:1 ]
   │
 1 │ let x = 1;
   │     ┬  
   │     ╰── first assignment to `x`
 2 │ x += 2;
   │ ───┬──  
   │    ╰──── cannot assign twice to immutable variable
   │
   ├─[ command_2:1:1 ]
   │
 1 │ let x = 1;
   │     │ 
   │     ╰─ help: consider making this binding mutable: `mut `
   │ 
   │ Note: You can change an existing variable to mutable like: `let mut x = x;`
───╯