File tree 1 file changed +33
-2
lines changed
1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -159,9 +159,40 @@ mod const_keyword { }
159
159
//
160
160
/// Skip to the next iteration of a loop.
161
161
///
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.
163
164
///
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
165
196
mod continue_keyword { }
166
197
167
198
#[ doc( keyword = "crate" ) ]
You can’t perform that action at this time.
0 commit comments