Skip to content

Commit

Permalink
Rollup merge of rust-lang#48151 - echochamber:update_range_example, r…
Browse files Browse the repository at this point in the history
…=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.
  • Loading branch information
kennytm authored Feb 13, 2018
2 parents 2deeb06 + bd426f1 commit c67b789
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ impl fmt::Debug for RangeFull {
/// assert_eq!((3..5), std::ops::Range { start: 3, end: 5 });
/// assert_eq!(3 + 4 + 5, (3..6).sum());
///
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ .. ], [0,1,2,3]);
/// assert_eq!(arr[ ..3], [0,1,2 ]);
/// assert_eq!(arr[1.. ], [ 1,2,3]);
/// assert_eq!(arr[1..3], [ 1,2 ]); // Range
/// let arr = ['a', 'b', 'c', 'd'];
/// assert_eq!(arr[ .. ], ['a', 'b', 'c', 'd']);
/// assert_eq!(arr[ ..3], ['a', 'b', 'c', ]);
/// assert_eq!(arr[1.. ], [ 'b', 'c', 'd']);
/// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
/// ```
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit c67b789

Please sign in to comment.