RustLoops


Syntax

  • loop { block } // infinite loop

  • while condition { block }

  • while let pattern = expr { block }

  • for pattern in expr { block } // expr must implement IntoIterator

  • continue // jump to the end of the loop body, starting a new iteration if necessary

  • break // stop the loop

  • 'label: loop { block }

  • 'label: while condition { block }

  • 'label: while let pattern = expr { block }

  • 'label: for pattern in expr { block }

  • continue 'label // jump to the end of the loop body labelled label, starting a new iteration if necessary

  • break 'label // stop the loop labelled label