@@ -807,64 +807,6 @@ mod in_keyword {}
807807/// [Reference]: ../reference/statements.html#let-statements
808808mod let_keyword { }
809809
810- #[ doc( keyword = "while" ) ]
811- //
812- /// Loop while a condition is upheld.
813- ///
814- /// A `while` expression is used for predicate loops. The `while` expression runs the conditional
815- /// expression before running the loop body, then runs the loop body if the conditional
816- /// expression evaluates to `true`, or exits the loop otherwise.
817- ///
818- /// ```rust
819- /// let mut counter = 0;
820- ///
821- /// while counter < 10 {
822- /// println!("{counter}");
823- /// counter += 1;
824- /// }
825- /// ```
826- ///
827- /// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression
828- /// cannot break with a value and always evaluates to `()` unlike [`loop`].
829- ///
830- /// ```rust
831- /// let mut i = 1;
832- ///
833- /// while i < 100 {
834- /// i *= 2;
835- /// if i == 64 {
836- /// break; // Exit when `i` is 64.
837- /// }
838- /// }
839- /// ```
840- ///
841- /// As `if` expressions have their pattern matching variant in `if let`, so too do `while`
842- /// expressions with `while let`. The `while let` expression matches the pattern against the
843- /// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise.
844- /// We can use `break` and `continue` in `while let` expressions just like in `while`.
845- ///
846- /// ```rust
847- /// let mut counter = Some(0);
848- ///
849- /// while let Some(i) = counter {
850- /// if i == 10 {
851- /// counter = None;
852- /// } else {
853- /// println!("{i}");
854- /// counter = Some (i + 1);
855- /// }
856- /// }
857- /// ```
858- ///
859- /// For more information on `while` and loops in general, see the [reference].
860- ///
861- /// See also, [`for`], [`loop`].
862- ///
863- /// [`for`]: keyword.for.html
864- /// [`loop`]: keyword.loop.html
865- /// [reference]: ../reference/expressions/loop-expr.html#predicate-loops
866- mod while_keyword { }
867-
868810#[ doc( keyword = "loop" ) ]
869811//
870812/// Loop indefinitely.
@@ -2343,6 +2285,64 @@ mod use_keyword {}
23432285/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/0135-where.md
23442286mod where_keyword { }
23452287
2288+ #[ doc( keyword = "while" ) ]
2289+ //
2290+ /// Loop while a condition is upheld.
2291+ ///
2292+ /// A `while` expression is used for predicate loops. The `while` expression runs the conditional
2293+ /// expression before running the loop body, then runs the loop body if the conditional
2294+ /// expression evaluates to `true`, or exits the loop otherwise.
2295+ ///
2296+ /// ```rust
2297+ /// let mut counter = 0;
2298+ ///
2299+ /// while counter < 10 {
2300+ /// println!("{counter}");
2301+ /// counter += 1;
2302+ /// }
2303+ /// ```
2304+ ///
2305+ /// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression
2306+ /// cannot break with a value and always evaluates to `()` unlike [`loop`].
2307+ ///
2308+ /// ```rust
2309+ /// let mut i = 1;
2310+ ///
2311+ /// while i < 100 {
2312+ /// i *= 2;
2313+ /// if i == 64 {
2314+ /// break; // Exit when `i` is 64.
2315+ /// }
2316+ /// }
2317+ /// ```
2318+ ///
2319+ /// As `if` expressions have their pattern matching variant in `if let`, so too do `while`
2320+ /// expressions with `while let`. The `while let` expression matches the pattern against the
2321+ /// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise.
2322+ /// We can use `break` and `continue` in `while let` expressions just like in `while`.
2323+ ///
2324+ /// ```rust
2325+ /// let mut counter = Some(0);
2326+ ///
2327+ /// while let Some(i) = counter {
2328+ /// if i == 10 {
2329+ /// counter = None;
2330+ /// } else {
2331+ /// println!("{i}");
2332+ /// counter = Some (i + 1);
2333+ /// }
2334+ /// }
2335+ /// ```
2336+ ///
2337+ /// For more information on `while` and loops in general, see the [reference].
2338+ ///
2339+ /// See also, [`for`], [`loop`].
2340+ ///
2341+ /// [`for`]: keyword.for.html
2342+ /// [`loop`]: keyword.loop.html
2343+ /// [reference]: ../reference/expressions/loop-expr.html#predicate-loops
2344+ mod while_keyword { }
2345+
23462346// 2018 Edition keywords
23472347
23482348#[ doc( alias = "promise" ) ]
0 commit comments