let mut variable: Type;
loop {
    variable = value;
}

or

loop {
    let variable: Type = value;
}
  • mina86
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 天前

    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 BorrowedBuf1).