Skip to content

Commit 577dbc8

Browse files
committed
Incorporate criticisms into keyword docs
Thanks to @Centril for these.
1 parent 50f631c commit 577dbc8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/libstd/keyword_docs.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#[doc(keyword = "as")]
1212
//
13-
/// The keyword for casting types.
13+
/// The keyword for casting a value to a type.
1414
///
1515
/// `as` is most commonly used to turn primitive types into other primitive types, but it has other
1616
/// uses that include turning pointers into addresses, addresses into pointers, and pointers into
@@ -133,7 +133,7 @@ mod crate_keyword { }
133133
///
134134
/// Enums in Rust are similar to those of other compiled languages like C, but have important
135135
/// 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
137137
/// important detail is that each enum variant can have data to go along with it.
138138
///
139139
/// ```rust
@@ -177,6 +177,7 @@ mod crate_keyword { }
177177
///
178178
/// For more information, take a look at the [Rust Book] or the [Reference]
179179
///
180+
/// [Algebraic Data Types]: https://en.wikipedia.org/wiki/Algebraic_data_type
180181
/// [`Option`]: option/enum.Option.html
181182
/// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html
182183
/// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html
@@ -442,11 +443,14 @@ mod if_keyword { }
442443
//
443444
/// The implementation-defining keyword.
444445
///
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()`.
450454
///
451455
/// ```rust
452456
/// struct Example {
@@ -551,7 +555,8 @@ mod impl_keyword { }
551555
///
552556
/// Other places the `let` keyword is used include along with [`if`], in the form of `if let`
553557
/// 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.
555560
///
556561
/// For more information on the `let` keyword, see the [Rust book] or the [Reference]
557562
///

0 commit comments

Comments
 (0)