Skip to content

Commit d5b8048

Browse files
authored
Rollup merge of #59456 - czipperz:for-keyword-document-higher-ranked-trait-bounds, r=Centril
Add documentation about `for` used as higher ranked trait bounds Resolves #55416
2 parents 2ee038a + 2545250 commit d5b8048

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/libstd/keyword_docs.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,16 @@ mod fn_keyword { }
286286
//
287287
/// The `for` keyword.
288288
///
289-
/// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic uses such as
290-
/// `impl Trait for Type` (see [`impl`] for more info on that). for-in-loops, or to be more
291-
/// precise, iterator loops, are a simple syntactic sugar over an exceedingly common practice
292-
/// within Rust, which is to loop over an iterator until that iterator returns `None` (or `break`
293-
/// is called).
289+
/// The `for` keyword is used in many syntactic locations:
290+
///
291+
/// * `for` is used in for-in-loops (see below).
292+
/// * `for` is used when implementing traits as in `impl Trait for Type` (see [`impl`] for more info
293+
/// on that).
294+
/// * `for` is also used for [higher-ranked trait bounds] as in `for<'a> &'a T: PartialEq<i32>`.
295+
///
296+
/// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common
297+
/// practice within Rust, which is to loop over an iterator until that iterator returns `None` (or
298+
/// `break` is called).
294299
///
295300
/// ```rust
296301
/// for i in 0..5 {
@@ -347,6 +352,8 @@ mod fn_keyword { }
347352
/// For more information on for-loops, see the [Rust book] or the [Reference].
348353
///
349354
/// [`impl`]: keyword.impl.html
355+
/// [higher-ranked trait bounds]:
356+
/// https://doc.rust-lang.org/nightly/reference/trait-bounds.html#higher-ranked-trait-bounds
350357
/// [`IntoIterator`]: iter/trait.IntoIterator.html
351358
/// [Rust book]:
352359
/// https://doc.rust-lang.org/book/2018-edition/ch03-05-control-flow.html#looping-through-a-collection-with-for

0 commit comments

Comments
 (0)