]> git.lizzy.rs Git - rust.git/commitdiff
split example into three sections with explanation
authorMatthew Piziak <matthew.piziak@gmail.com>
Thu, 18 Aug 2016 20:12:40 +0000 (16:12 -0400)
committerMatthew Piziak <matthew.piziak@gmail.com>
Thu, 18 Aug 2016 20:12:40 +0000 (16:12 -0400)
src/libcore/ops.rs

index cee374ccc7bc5e84fe8e9e1dc6a7b7f1f6ebca1f..932e5f086cbbe70b30e026becb6f73f0e3fdb9d0 100644 (file)
@@ -1462,13 +1462,24 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
 ///
 /// # Examples
 ///
+/// The `..` syntax is a `RangeFull`:
+///
 /// ```
 /// assert_eq!((..), std::ops::RangeFull);
+/// ```
 ///
-/// // for i in .. {
-/// //     println!("This errors because .. has no IntoIterator impl");
-/// // }
+/// It does not have an `IntoIterator` implementation, so you can't use it in a
+/// `for` loop directly. This won't compile:
 ///
+/// ```ignore
+/// for i in .. {
+///    // ...
+/// }
+/// ```
+///
+/// Used as a slicing index, `RangeFull` produces the full array as a slice.
+///
+/// ```
 /// let arr = [0, 1, 2, 3];
 /// assert_eq!(arr[ .. ], [0,1,2,3]);  // RangeFull
 /// assert_eq!(arr[ ..3], [0,1,2  ]);