Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0203: Assign to immutable

CodeCategoryStability
E0203SemanticPermanent

Explanation

Rue rejected a write because the place written belongs to a binding that was not declared mutable: an assignment target, an inout argument, or the receiver of an inout self method.

Likely cause

A variable, array, or struct value was introduced with let (or is a by-value parameter) and later assigned to, passed inout, or used as an inout self receiver. 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
}

References