Skip to main content

E0003: Assignment Type Mismatch

You tried to assign a value of a different type to a variable.

Example

fn main() {
let mut x: i64 = 5;
x = true; // Error: cannot assign value of type `bool` to variable `x` of type `i64`
}

How to fix

Assign a value of the correct type:

fn main() {
let mut x: i64 = 5;
x = 10; // OK
}

Or change the variable's type if appropriate:

fn main() {
let mut x: bool = false;
x = true; // OK
}