@@ -26,11 +26,13 @@ use hash::{Hash, Hasher};
26
26
/// Used as a [slicing index], `RangeFull` produces the full array as a slice.
27
27
///
28
28
/// ```
29
- /// let arr = [0, 1, 2, 3];
30
- /// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
31
- /// assert_eq!(arr[ ..3], [0,1,2 ]);
32
- /// assert_eq!(arr[1.. ], [ 1,2,3]);
33
- /// assert_eq!(arr[1..3], [ 1,2 ]);
29
+ /// let arr = [0, 1, 2, 3, 4];
30
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]); // RangeFull
31
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]);
32
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]);
33
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]);
34
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]);
35
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]);
34
36
/// ```
35
37
///
36
38
/// [`IntoIterator`]: ../iter/trait.Iterator.html
@@ -60,11 +62,13 @@ impl fmt::Debug for RangeFull {
60
62
/// assert_eq!((3..5), std::ops::Range { start: 3, end: 5 });
61
63
/// assert_eq!(3 + 4 + 5, (3..6).sum());
62
64
///
63
- /// let arr = ['a', 'b', 'c', 'd'];
64
- /// assert_eq!(arr[ .. ], ['a', 'b', 'c', 'd']);
65
- /// assert_eq!(arr[ ..3], ['a', 'b', 'c', ]);
66
- /// assert_eq!(arr[1.. ], [ 'b', 'c', 'd']);
67
- /// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
65
+ /// let arr = [0, 1, 2, 3, 4];
66
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]);
67
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]);
68
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]);
69
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]);
70
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]); // Range
71
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]);
68
72
/// ```
69
73
#[ doc( alias = ".." ) ]
70
74
#[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
@@ -160,11 +164,13 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
160
164
/// assert_eq!((2..), std::ops::RangeFrom { start: 2 });
161
165
/// assert_eq!(2 + 3 + 4, (2..).take(3).sum());
162
166
///
163
- /// let arr = [0, 1, 2, 3];
164
- /// assert_eq!(arr[ .. ], [0,1,2,3]);
165
- /// assert_eq!(arr[ ..3], [0,1,2 ]);
166
- /// assert_eq!(arr[1.. ], [ 1,2,3]); // RangeFrom
167
- /// assert_eq!(arr[1..3], [ 1,2 ]);
167
+ /// let arr = [0, 1, 2, 3, 4];
168
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]);
169
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]);
170
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]);
171
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]); // RangeFrom
172
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]);
173
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]);
168
174
/// ```
169
175
///
170
176
/// [`Iterator`]: ../iter/trait.IntoIterator.html
@@ -240,11 +246,13 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
240
246
/// elements before the index indicated by `end`.
241
247
///
242
248
/// ```
243
- /// let arr = [0, 1, 2, 3];
244
- /// assert_eq!(arr[ .. ], [0,1,2,3]);
245
- /// assert_eq!(arr[ ..3], [0,1,2 ]); // RangeTo
246
- /// assert_eq!(arr[1.. ], [ 1,2,3]);
247
- /// assert_eq!(arr[1..3], [ 1,2 ]);
249
+ /// let arr = [0, 1, 2, 3, 4];
250
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]);
251
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]); // RangeTo
252
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]);
253
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]);
254
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]);
255
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]);
248
256
/// ```
249
257
///
250
258
/// [`IntoIterator`]: ../iter/trait.Iterator.html
@@ -312,9 +320,13 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
312
320
/// assert_eq!((3..=5), std::ops::RangeInclusive::new(3, 5));
313
321
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
314
322
///
315
- /// let arr = [0, 1, 2, 3];
316
- /// assert_eq!(arr[ ..=2], [0,1,2 ]);
317
- /// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
323
+ /// let arr = [0, 1, 2, 3, 4];
324
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]);
325
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]);
326
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]);
327
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]);
328
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]);
329
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]); // RangeInclusive
318
330
/// ```
319
331
#[ doc( alias = "..=" ) ]
320
332
#[ derive( Clone ) ] // not Copy -- see #27186
@@ -569,9 +581,13 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
569
581
/// array elements up to and including the index indicated by `end`.
570
582
///
571
583
/// ```
572
- /// let arr = [0, 1, 2, 3];
573
- /// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
574
- /// assert_eq!(arr[1..=2], [ 1,2 ]);
584
+ /// let arr = [0, 1, 2, 3, 4];
585
+ /// assert_eq!(arr[ .. ], [0,1,2,3,4]);
586
+ /// assert_eq!(arr[ .. 3], [0,1,2 ]);
587
+ /// assert_eq!(arr[ ..=3], [0,1,2,3 ]); // RangeToInclusive
588
+ /// assert_eq!(arr[1.. ], [ 1,2,3,4]);
589
+ /// assert_eq!(arr[1.. 3], [ 1,2 ]);
590
+ /// assert_eq!(arr[1..=3], [ 1,2,3 ]);
575
591
/// ```
576
592
///
577
593
/// [`IntoIterator`]: ../iter/trait.Iterator.html
0 commit comments