about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-26 14:17:46 +0200
committerGitHub <noreply@github.com>2019-10-26 14:17:46 +0200
commit7325a886e253a0632a9c346cfccd201323c74ee8 (patch)
treeaa68f297067bab0f7dd861ca0fba2d110c5777bb /src/libstd
parent0aa7c6f96b2dfed47f750b26514191353084c889 (diff)
parent9733b0f122db7eb7662799b164bc02b0f54cb84a (diff)
downloadrust-7325a886e253a0632a9c346cfccd201323c74ee8.tar.gz
rust-7325a886e253a0632a9c346cfccd201323c74ee8.zip
Rollup merge of #65791 - dorfsmay:doc_keyword_continue, r=Mark-Simulacrum
Adding doc on keyword continue

Partial solution of issue #34601.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/keyword_docs.rs35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs
index ab8a55660cb..d025a7d16f2 100644
--- a/src/libstd/keyword_docs.rs
+++ b/src/libstd/keyword_docs.rs
@@ -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")]