Skip to content

Commit 377ae44

Browse files
explicitly show how iterating over .. fails
I've also removed the `main()` wrapper, which I believe is extraneous. LMK if that's incorrect.
1 parent 11f8805 commit 377ae44

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/libcore/ops.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,15 +1463,17 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
14631463
/// # Examples
14641464
///
14651465
/// ```
1466-
/// fn main() {
1467-
/// assert_eq!((..), std::ops::RangeFull);
1466+
/// assert_eq!((..), std::ops::RangeFull);
14681467
///
1469-
/// let arr = [0, 1, 2, 3];
1470-
/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
1471-
/// assert_eq!(arr[ ..3], [0,1,2 ]);
1472-
/// assert_eq!(arr[1.. ], [ 1,2,3]);
1473-
/// assert_eq!(arr[1..3], [ 1,2 ]);
1474-
/// }
1468+
/// // for i in .. {
1469+
/// // println!("This errors because .. has no Iterator impl");
1470+
/// // }
1471+
///
1472+
/// let arr = [0, 1, 2, 3];
1473+
/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
1474+
/// assert_eq!(arr[ ..3], [0,1,2 ]);
1475+
/// assert_eq!(arr[1.. ], [ 1,2,3]);
1476+
/// assert_eq!(arr[1..3], [ 1,2 ]);
14751477
/// ```
14761478
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
14771479
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)