0

Rust – error[E0596]: cannot borrow variable as mutable, as it is not declared as mutable

By default, variables are immutable in Rust. This means we cannot replace the variable’s value or, for non-scalar values, modify its contents.

Sample Erring Codes

Output

How to Fix

To make a variable mutable, use the mut keyword between the let keyword and variable name. For example:

Output

Karl San Gabriel

Karl San Gabriel

Professional Software Developer