File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1479,17 +1479,28 @@ mod true_keyword {}
14791479/// assert_eq!(m, k);
14801480/// ```
14811481///
1482- /// In traits, using `type` allows the usage of an associated type without
1483- /// knowing about it when declaring the [`trait`]:
1482+ /// In traits, `type` is used to declare an [associated type]:
14841483///
14851484/// ```rust
14861485/// trait Iterator {
1486+ /// // associated type declaration
14871487/// type Item;
14881488/// fn next(&mut self) -> Option<Self::Item>;
14891489/// }
1490+ ///
1491+ /// struct Once<T>(Option<T>);
1492+ ///
1493+ /// impl<T> Iterator for Once<T> {
1494+ /// // associated type definition
1495+ /// type Item = T;
1496+ /// fn next(&mut self) -> Option<Self::Item> {
1497+ /// self.0.take()
1498+ /// }
1499+ /// }
14901500/// ```
14911501///
14921502/// [`trait`]: keyword.trait.html
1503+ /// [associated type]: ../reference/items/associated-items.html#associated-types
14931504mod type_keyword { }
14941505
14951506#[ doc( keyword = "unsafe" ) ]
You can’t perform that action at this time.
0 commit comments