Skip to content

Commit b4b49eb

Browse files
committed
Rollup merge of #48151 - echochamber:update_range_example, r=estebank Update ops range example to avoid confusion between indexes and values. Makes clearer the numbers in the range refer to indexes, not the values at those indexes.
2 parents 2fa76cd + bd426f1 commit b4b49eb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libcore/ops/range.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ impl fmt::Debug for RangeFull {
6868
/// assert_eq!((3..5), std::ops::Range { start: 3, end: 5 });
6969
/// assert_eq!(3 + 4 + 5, (3..6).sum());
7070
///
71-
/// let arr = [0, 1, 2, 3];
72-
/// assert_eq!(arr[ .. ], [0,1,2,3]);
73-
/// assert_eq!(arr[ ..3], [0,1,2 ]);
74-
/// assert_eq!(arr[1.. ], [ 1,2,3]);
75-
/// assert_eq!(arr[1..3], [ 1,2 ]); // Range
71+
/// let arr = ['a', 'b', 'c', 'd'];
72+
/// assert_eq!(arr[ .. ], ['a', 'b', 'c', 'd']);
73+
/// assert_eq!(arr[ ..3], ['a', 'b', 'c', ]);
74+
/// assert_eq!(arr[1.. ], [ 'b', 'c', 'd']);
75+
/// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
7676
/// ```
7777
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
7878
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)