|
10 | 10 |
|
11 | 11 | #[doc(keyword = "as")] |
12 | 12 | // |
13 | | -/// The keyword for casting types. |
| 13 | +/// The keyword for casting a value to a type. |
14 | 14 | /// |
15 | 15 | /// `as` is most commonly used to turn primitive types into other primitive types, but it has other |
16 | 16 | /// uses that include turning pointers into addresses, addresses into pointers, and pointers into |
@@ -133,7 +133,7 @@ mod crate_keyword { } |
133 | 133 | /// |
134 | 134 | /// Enums in Rust are similar to those of other compiled languages like C, but have important |
135 | 135 | /// differences that make them considerably more powerful. What Rust calls enums are more commonly |
136 | | -/// known as Algebraic Data Types if you're coming from a functional programming background. The |
| 136 | +/// known as [Algebraic Data Types] if you're coming from a functional programming background. The |
137 | 137 | /// important detail is that each enum variant can have data to go along with it. |
138 | 138 | /// |
139 | 139 | /// ```rust |
@@ -177,6 +177,7 @@ mod crate_keyword { } |
177 | 177 | /// |
178 | 178 | /// For more information, take a look at the [Rust Book] or the [Reference] |
179 | 179 | /// |
| 180 | +/// [Algebraic Data Types]: https://en.wikipedia.org/wiki/Algebraic_data_type |
180 | 181 | /// [`Option`]: option/enum.Option.html |
181 | 182 | /// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html |
182 | 183 | /// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html |
@@ -442,11 +443,14 @@ mod if_keyword { } |
442 | 443 | // |
443 | 444 | /// The implementation-defining keyword. |
444 | 445 | /// |
445 | | -/// The `impl` keyword is primarily used for defining implementations on types. There are two kinds |
446 | | -/// of implementations: Inherent implementations and trait implementations. Inherent |
447 | | -/// implementations define functions that operate on a type, known in object-oriented languages as |
448 | | -/// methods. Trait implementations are used to give a type a trait, and implement any of the |
449 | | -/// required associated items or methods that it requires. |
| 446 | +/// The `impl` keyword is primarily used to define implementations on types. Inherent |
| 447 | +/// implementations are standalone, while trait implementations are used to implement traits for |
| 448 | +/// types, or other traits. |
| 449 | +/// |
| 450 | +/// Functions and consts can both be defined in an implementation. A function defined in an |
| 451 | +/// `impl` block can be standalone, meaning it would be called like `Foo::bar()`. If the function |
| 452 | +/// takes `self`, `&self`, or `&mut self` as its first argument, it can also be called using |
| 453 | +/// method-call syntax, a familiar feature to any object oriented programmer, like `foo.bar()`. |
450 | 454 | /// |
451 | 455 | /// ```rust |
452 | 456 | /// struct Example { |
@@ -551,7 +555,8 @@ mod impl_keyword { } |
551 | 555 | /// |
552 | 556 | /// Other places the `let` keyword is used include along with [`if`], in the form of `if let` |
553 | 557 | /// expressions. They're useful if the pattern being matched isn't exhaustive, such as with |
554 | | -/// enumerations. |
| 558 | +/// enumerations. `while let` also exists, which runs a loop with a pattern matched value until |
| 559 | +/// that pattern can't be matched. |
555 | 560 | /// |
556 | 561 | /// For more information on the `let` keyword, see the [Rust book] or the [Reference] |
557 | 562 | /// |
|
0 commit comments