E0203: Assign to immutable
| Code | Category | Stability |
|---|---|---|
E0203 | Semantic | Permanent |
Explanation
Rue rejected an assignment because its target belongs to a binding that was not declared mutable.
Likely cause
A variable, array, or struct value was introduced with let and later used as an assignment target. Bind it with let mut when mutation is intended.
Examples
Assignment to an immutable binding
fn main() -> i32 {
let value = 0;
value = 42;
value
}
Declare the binding mutable
fn main() -> i32 {
let mut value = 0;
value = 42;
value
}