I would say that they are equivalent. If I’m not mistaken, let
statements only reserves space on the stack, and this only increments the stack register.
And on the latter snippet, the compiler would certainly not bother to modify the stack pointer as the type doesn’t change.
according to godbolt: https://rust.godbolt.org/z/hP5Y3qMPW
use rand::random; pub fn main1() { let mut var : u128; loop { var = random(); } } pub fn main2() { loop { let var : u128 = random(); } }
compiles to:
So yeah, exactly the same thing.