Skip to content

Commit 9733b0f

Browse files
committed
Adding doc on keyword continue
1 parent 10a52c2 commit 9733b0f

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/libstd/keyword_docs.rs

+33-2
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,40 @@ mod const_keyword { }
159159
//
160160
/// Skip to the next iteration of a loop.
161161
///
162-
/// The documentation for this keyword is [not yet complete]. Pull requests welcome!
162+
/// When `continue` is encountered, the current iteration is terminated, returning control to the
163+
/// loop head, typically continuing with the next iteration.
163164
///
164-
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
165+
///```rust
166+
/// // Printing odd numbers by skipping even ones
167+
/// for number in 1..=10 {
168+
/// if number % 2 == 0 {
169+
/// continue;
170+
/// }
171+
/// println!("{}", number);
172+
/// }
173+
///```
174+
///
175+
/// Like `break`, `continue` is normally associated with the innermost enclosing loop, but labels
176+
/// may be used to specify the affected loop.
177+
///
178+
///```rust
179+
/// // Print Odd numbers under 30 with unit <= 5
180+
/// 'tens: for ten in 0..3 {
181+
/// 'units: for unit in 0..=9 {
182+
/// if unit % 2 == 0 {
183+
/// continue;
184+
/// }
185+
/// if unit > 5 {
186+
/// continue 'tens;
187+
/// }
188+
/// println!("{}", ten * 10 + unit);
189+
/// }
190+
/// }
191+
///```
192+
///
193+
/// See [continue expressions] from the reference for more details.
194+
///
195+
/// [continue expressions]: ../reference/expressions/loop-expr.html#continue-expressions
165196
mod continue_keyword { }
166197

167198
#[doc(keyword = "crate")]

0 commit comments

Comments
 (0)