Skip to content

Commit dcb1bd1

Browse files
committed
add documentation for the while keyword
while keyword is used to define while loops in rust. Fixes #60736.
1 parent efa3c27 commit dcb1bd1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/libstd/keyword_docs.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,28 @@ mod impl_keyword { }
558558
/// [Reference]: ../reference/statements.html#let-statements
559559
mod let_keyword { }
560560

561+
#[doc(keyword = "while")]
562+
//
563+
/// while loop
564+
///
565+
/// `while` is used to define while loops in Rust. It runs the code inside it
566+
/// until the condition in the while loop becomes False or there the code uses
567+
/// `break`.
568+
///
569+
///
570+
/// ```rust
571+
/// let mut i = 0;
572+
/// while i > 10 {
573+
/// println!("i is {}", i);
574+
/// i += 1;
575+
/// }
576+
/// ```
577+
///
578+
/// For more information on `while` and loops in general, see the [Reference].
579+
///
580+
/// [Reference]: ../reference/expressions/loop-expr.html
581+
mod while_keyword { }
582+
561583
#[doc(keyword = "loop")]
562584
//
563585
/// The loop-defining keyword.

0 commit comments

Comments
 (0)