The correct syntax
let (mut a, mut b, mut c) = (1, 0.0, 3);
Mutability is a binding property, and a , b and c are all different bindings, each of which is bound to a specific element of the tuple after matching the template. Thus, they can be individually changed.
If you want to specify a type, you can do this too:
let (mut a, mut b, mut c): (u8, f32, i32) = (1, 0.0, 3);
For numeric literals, you can also use the suffix form:
let (mut a, mut b, mut c) = (1u8, 0.0f32, 3i32);
Of course, there is no reason to do this for example code; itβs much easier to just have 3 separate operators.
declare several constants
These are not constants, they are just immutable variables. A const is a different concept.
Shepmaster
source share