Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Loop expressions

LoopExpression      =     "loop" , BlockExpression
                    ;

const-loop preview feature

Warning

Requires const-loop preview feature enabled.

Using a loop expression inside a const item’s initializer requires the const-loop preview feature to be enabled:

const SUM: u8 = {
    let i = 0;
    let sum = 0;
    loop {
        if i == 5 then {
            break;
        }
        sum = sum + i;
        i = i + 1;
    }
    yield sum; // requires `const-loop`
};