@@ -234,12 +234,55 @@ mod crate_keyword {}
234234
235235#[ doc( keyword = "else" ) ]
236236//
237- /// What to do when an [`if`] condition does not hold .
237+ /// What expression to evaluate when an [`if`] condition evaluates to [`false`] .
238238///
239- /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
239+ /// `else` expressions are optional. When no else expressions are supplied it is assumed to evaluate
240+ /// to the unit type `()`.
241+ ///
242+ /// The type that the `else` blocks evaluate to must be compatible with the type that the `if` block
243+ /// evaluates to.
244+ ///
245+ /// As can be seen below, `else` must be followed by either: `if`, `if let`, or a block `{}` and it
246+ /// will return the value of that expression.
240247///
248+ /// ```rust
249+ /// let result = if true == false {
250+ /// "oh no"
251+ /// } else if "something" == "other thing" {
252+ /// "oh dear"
253+ /// } else if let Some(200) = "blarg".parse::<i32>().ok() {
254+ /// "uh oh"
255+ /// } else {
256+ /// println!("Sneaky side effect.");
257+ /// "phew, nothing's broken"
258+ /// };
259+ /// ```
260+ ///
261+ /// Here's another example but here we do not try and return an expression:
262+ ///
263+ /// ```rust
264+ /// if true == false {
265+ /// println!("oh no");
266+ /// } else if "something" == "other thing" {
267+ /// println!("oh dear");
268+ /// } else if let Some(200) = "blarg".parse::<i32>().ok() {
269+ /// println!("uh oh");
270+ /// } else {
271+ /// println!("phew, nothing's broken");
272+ /// }
273+ /// ```
274+ ///
275+ /// The above is _still_ an expression but it will always evaluate to `()`.
276+ ///
277+ /// There is possibly no limit to the number of `else` blocks that could follow an `if` expression
278+ /// however if you have several then a [`match`] expression might be preferable.
279+ ///
280+ /// Read more about control flow in the [Rust Book].
281+ ///
282+ /// [Rust Book]: ../book/ch03-05-control-flow.html#handling-multiple-conditions-with-else-if
283+ /// [`match`]: keyword.match.html
284+ /// [`false`]: keyword.false.html
241285/// [`if`]: keyword.if.html
242- /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
243286mod else_keyword { }
244287
245288#[ doc( keyword = "enum" ) ]
@@ -637,10 +680,18 @@ mod impl_keyword {}
637680//
638681/// Iterate over a series of values with [`for`].
639682///
640- /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
683+ /// The expression immediately following `in` must implement the [`Iterator`] trait.
641684///
685+ /// ## Literal Examples:
686+ ///
687+ /// * `for _ **in** 1..3 {}` - Iterate over an exclusive range up to but excluding 3.
688+ /// * `for _ **in** 1..=3 {}` - Iterate over an inclusive range up to and includeing 3.
689+ ///
690+ /// (Read more about [range patterns])
691+ ///
692+ /// [`Iterator`]: ../book/ch13-04-performance.html
693+ /// [`range patterns`]: ../reference/patterns.html?highlight=range#range-patterns
642694/// [`for`]: keyword.for.html
643- /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
644695mod in_keyword { }
645696
646697#[ doc( keyword = "let" ) ]
0 commit comments