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

Оператор loop просто повторюється до нескінченності, поки не трапиться break.

fn main() {
    let mut i = 0;
    loop {
        i += 1;
        println!("{i}");
        if i > 100 {
            break;
        }
    }
}
  • The loop statement works like a while true loop. Use it for things like servers which will serve connections forever.