Skip to content

Commit

Permalink
Explicit mention of slice range meaning
Browse files Browse the repository at this point in the history
In `&ys[1 .. 4]` i did not understand whether 4 meant the length or the end index. This is to prevent other readers from having the same confusion.
  • Loading branch information
kishaningithub authored Oct 5, 2019
1 parent a6288e7 commit 6e19226
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/primitives/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ fn main() {
analyze_slice(&xs);
// Slices can point to a section of an array
// They are of the form [starting_index..ending_index]
// starting_index is the first position in the slice
// ending_index is one more than the last position in the slice
println!("borrow a section of the array as a slice");
analyze_slice(&ys[1 .. 4]);
Expand Down

0 comments on commit 6e19226

Please sign in to comment.