From 377ae44cf276599a5b7a21e545d83372067db754 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Mon, 15 Aug 2016 18:46:19 -0400 Subject: [PATCH] explicitly show how iterating over `..` fails I've also removed the `main()` wrapper, which I believe is extraneous. LMK if that's incorrect. --- src/libcore/ops.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 9347ac2a8c82..558b78a2fbfa 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1463,15 +1463,17 @@ pub trait IndexMut: Index { /// # Examples /// /// ``` -/// fn main() { -/// assert_eq!((..), std::ops::RangeFull); +/// assert_eq!((..), std::ops::RangeFull); /// -/// let arr = [0, 1, 2, 3]; -/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull -/// assert_eq!(arr[ ..3], [0,1,2 ]); -/// assert_eq!(arr[1.. ], [ 1,2,3]); -/// assert_eq!(arr[1..3], [ 1,2 ]); -/// } +/// // for i in .. { +/// // println!("This errors because .. has no Iterator impl"); +/// // } +/// +/// let arr = [0, 1, 2, 3]; +/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull +/// assert_eq!(arr[ ..3], [0,1,2 ]); +/// assert_eq!(arr[1.. ], [ 1,2,3]); +/// assert_eq!(arr[1..3], [ 1,2 ]); /// ``` #[derive(Copy, Clone, PartialEq, Eq, Hash)] #[stable(feature = "rust1", since = "1.0.0")]