-
Notifications
You must be signed in to change notification settings - Fork 13.3k
add documentation for the while keyword #60761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -558,6 +558,28 @@ mod impl_keyword { } | |
/// [Reference]: ../reference/statements.html#let-statements | ||
mod let_keyword { } | ||
|
||
#[doc(keyword = "while")] | ||
// | ||
/// while loop | ||
/// | ||
/// `while` is used to define while loops in Rust. It runs the code inside it | ||
/// until the condition in the while loop becomes False or there the code uses | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capitalization: false is a lowercase noun. This looks like muscle memory from Python. ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should also use an inline code block (back ticks) around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "until the condition becomes false" is meaningful English without backticks. I think adding backticks would detract in this case. |
||
/// `break`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This "until there" part of the sentence sounds wrong to me. Not clear what "there" is referring to. |
||
/// | ||
/// | ||
/// ```rust | ||
/// let mut i = 0; | ||
/// while i > 10 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 is not > 10 so this loop would never run -- seems unintentional. |
||
/// println!("i is {}", i); | ||
/// i += 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please come up with a different example where |
||
/// } | ||
/// ``` | ||
/// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This page should cover |
||
/// For more information on `while` and loops in general, see the [Reference]. | ||
/// | ||
/// [Reference]: ../reference/expressions/loop-expr.html | ||
mod while_keyword { } | ||
|
||
#[doc(keyword = "loop")] | ||
// | ||
/// The loop-defining keyword. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write this in a way that is not a tautology ("the while keyword is used to define a while loop"). It is true but not meaningful.