I am new to rust and trying to get to grips with the fundamentals.
I am trying to do a multiple-assignment as follows.
let (a,b:i64,c) = (43,4563459682450968,"Hello World");
Now I deliberately put the 2nd value quite big, and tried to specify the type as i64
But this returns an error. It isn't the same as declaring it separately with i64.
May I know how I can explicitly specify the type in a multiple assignment statement?
Rust does not have multiple assignment as a fundamental feature; it has patterns as a fundamental feature. The syntax of let is (loosely speaking)
let PATTERN : TYPE = EXPRESSION;
What your statement is actually doing is constructing a 3-element tuple, then taking it apart again. So, you need to specify the type of the tuple (which you can do in whole or in part):
let (a, b, c): (_, i64, _) = (43, 4563459682450968, "Hello World");
// or
let (a, b, c): (i32, i64, &str) = (43, 4563459682450968, "Hello World");
The _ stands for an unspecified type (in the same way as if you did not write any type for the let, but just for that part).