By default when declaring a variable that becomes immutable, however, it is possible to make it mutable by adding the mut keyword like so let mut number.
In some ways this perspective — fuelled by the chosen syntax — is bound to create confusion later.
When it comes to Rust train your brain ASAP to make the following automatic substitutions:
immutable -> shared access
mutable -> exclusive access (unique)
i.e. "shared" values cannot be mutated and "exclusive" values cannot be "shared".
The immutable ⟷ mutable tension is only a consequence of the primary shared ⟷ exclusive tension.
By default values are assumed to have shared access and therefore have to be explicitly marked for exclusive access (mut).
In some ways this perspective — fuelled by the chosen syntax — is bound to create confusion later.
When it comes to Rust train your brain ASAP to make the following automatic substitutions:
i.e. "shared" values cannot be mutated and "exclusive" values cannot be "shared".
The immutable ⟷ mutable tension is only a consequence of the primary shared ⟷ exclusive tension.
By default values are assumed to have shared access and therefore have to be explicitly marked for exclusive access (
mut
).See
Nice thank you the tips, specially that link about ownership is a lot at first