mirror of
https://github.com/rust-lang/book.git
synced 2026-05-16 12:41:32 -04:00
Merge pull request #1368 from ajuckel/slice-off-by-one
Fix off-by-one error in slice example
This commit is contained in:
@@ -158,7 +158,7 @@ in the slice and `ending_index` is one more than the last position in the
|
||||
slice. Internally, the slice data structure stores the starting position and
|
||||
the length of the slice, which corresponds to `ending_index` minus
|
||||
`starting_index`. So in the case of `let world = &s[6..11];`, `world` would be
|
||||
a slice that contains a pointer to the 6th byte of `s` and a length value of 5.
|
||||
a slice that contains a pointer to the 7th byte of `s` and a length value of 5.
|
||||
|
||||
Figure 4-6 shows this in a diagram.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user