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

or

loop {
    let variable: Type = value;
}
  • Giooschi@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    12 hours ago

    let statements only reserves space on the stack

    It is not guaranteed to do that. It could also use a register or be optimized out completly (like in the example you posted in the other comment).

    The stack pointer is also not changed for each local variable, but instead for each function call, so it wouldn’t make a difference anyway.