File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -1463,9 +1463,33 @@ mod true_keyword {}
14631463//
14641464/// Define an alias for an existing type.
14651465///
1466- /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
1466+ /// The syntax is `type Name = ExistingType;`.
14671467///
1468- /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
1468+ /// # Examples
1469+ ///
1470+ /// `type` does **not** create a new type:
1471+ ///
1472+ /// ```rust
1473+ /// type Meters = u32;
1474+ /// type Kilograms = u32;
1475+ ///
1476+ /// let m: Meters = 3;
1477+ /// let k: Kilograms = 3;
1478+ ///
1479+ /// assert_eq!(m, k);
1480+ /// ```
1481+ ///
1482+ /// In traits, using `type` allows the usage of an associated type without
1483+ /// knowing about it when declaring the [`trait`]:
1484+ ///
1485+ /// ```rust
1486+ /// trait Iterator {
1487+ /// type Item;
1488+ /// fn next(&mut self) -> Option<Self::Item>;
1489+ /// }
1490+ /// ```
1491+ ///
1492+ /// [`trait`]: keyword.trait.html
14691493mod type_keyword { }
14701494
14711495#[ doc( keyword = "unsafe" ) ]
You can’t perform that action at this time.
0 commit comments