diff options
| author | Matthew Piziak <matthew.piziak@gmail.com> | 2016-08-15 18:46:19 -0400 |
|---|---|---|
| committer | Matthew Piziak <matthew.piziak@gmail.com> | 2016-08-15 18:46:19 -0400 |
| commit | 377ae44cf276599a5b7a21e545d83372067db754 (patch) | |
| tree | 1697c1a78a7dda0f67bd6de0c4311e22685579d2 /src/libcore | |
| parent | 11f880588791930cb130071c2cb972fc3c3354ed (diff) | |
explicitly show how iterating over `..` fails
I've also removed the `main()` wrapper, which I believe is extraneous. LMK if that's incorrect.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ops.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 9347ac2a8c8..558b78a2fbf 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1463,15 +1463,17 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> { /// # 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")] |
