Skip to content

Commit

Permalink
Adding doc on keyword continue
Browse files Browse the repository at this point in the history
  • Loading branch information
dorfsmay committed Oct 25, 2019
1 parent 10a52c2 commit 9733b0f
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/libstd/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,40 @@ mod const_keyword { }
//
/// Skip to the next iteration of a loop.
///
/// The documentation for this keyword is [not yet complete]. Pull requests welcome!
/// When `continue` is encountered, the current iteration is terminated, returning control to the
/// loop head, typically continuing with the next iteration.
///
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
///```rust
/// // Printing odd numbers by skipping even ones
/// for number in 1..=10 {
/// if number % 2 == 0 {
/// continue;
/// }
/// println!("{}", number);
/// }
///```
///
/// Like `break`, `continue` is normally associated with the innermost enclosing loop, but labels
/// may be used to specify the affected loop.
///
///```rust
/// // Print Odd numbers under 30 with unit <= 5
/// 'tens: for ten in 0..3 {
/// 'units: for unit in 0..=9 {
/// if unit % 2 == 0 {
/// continue;
/// }
/// if unit > 5 {
/// continue 'tens;
/// }
/// println!("{}", ten * 10 + unit);
/// }
/// }
///```
///
/// See [continue expressions] from the reference for more details.
///
/// [continue expressions]: ../reference/expressions/loop-expr.html#continue-expressions
mod continue_keyword { }

#[doc(keyword = "crate")]
Expand Down

0 comments on commit 9733b0f

Please sign in to comment.