Which is faster?
Which is faster?
let mut variable: Type; loop { variable = value; }
or
loop { let variable: Type = value; }
Which is faster?
let mut variable: Type; loop { variable = value; }
or
loop { let variable: Type = value; }
You're viewing a single thread.
This is too simplistic example to give any meaningful answer. What’s Type
? What’s value
? If it’s i32
and 42
than they both compile to the exact same thing. But if Type
is Drop
than the second will call the destructor on each iteration. (I’ve also written previously about similar example with BorrowedBuf
1).