File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1479,17 +1479,28 @@ mod true_keyword {}
1479
1479
/// assert_eq!(m, k);
1480
1480
/// ```
1481
1481
///
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]:
1484
1483
///
1485
1484
/// ```rust
1486
1485
/// trait Iterator {
1486
+ /// // associated type declaration
1487
1487
/// type Item;
1488
1488
/// fn next(&mut self) -> Option<Self::Item>;
1489
1489
/// }
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
+ /// }
1490
1500
/// ```
1491
1501
///
1492
1502
/// [`trait`]: keyword.trait.html
1503
+ /// [associated type]: ../reference/items/associated-items.html#associated-types
1493
1504
mod type_keyword { }
1494
1505
1495
1506
#[ doc( keyword = "unsafe" ) ]
You can’t perform that action at this time.
0 commit comments