@@ -1467,17 +1467,30 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
1467
1467
///
1468
1468
/// # Examples
1469
1469
///
1470
+ /// The `..` syntax is a `RangeFull`:
1471
+ ///
1472
+ /// ```
1473
+ /// assert_eq!((..), std::ops::RangeFull);
1470
1474
/// ```
1471
- /// fn main() {
1472
- /// assert_eq!((..), std::ops::RangeFull);
1473
1475
///
1474
- /// let arr = [0, 1, 2, 3];
1475
- /// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
1476
- /// assert_eq!(arr[ ..3], [0,1,2 ]);
1477
- /// assert_eq!(arr[1.. ], [ 1,2,3]);
1478
- /// assert_eq!(arr[1..3], [ 1,2 ]);
1476
+ /// It does not have an `IntoIterator` implementation, so you can't use it in a
1477
+ /// `for` loop directly. This won't compile:
1478
+ ///
1479
+ /// ```ignore
1480
+ /// for i in .. {
1481
+ /// // ...
1479
1482
/// }
1480
1483
/// ```
1484
+ ///
1485
+ /// Used as a slicing index, `RangeFull` produces the full array as a slice.
1486
+ ///
1487
+ /// ```
1488
+ /// let arr = [0, 1, 2, 3];
1489
+ /// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
1490
+ /// assert_eq!(arr[ ..3], [0,1,2 ]);
1491
+ /// assert_eq!(arr[1.. ], [ 1,2,3]);
1492
+ /// assert_eq!(arr[1..3], [ 1,2 ]);
1493
+ /// ```
1481
1494
#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
1482
1495
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1483
1496
pub struct RangeFull ;
0 commit comments