1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-12 13:25:23 +02:00

Update src/basic-syntax/slices.md

Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
Robin Stringer 2023-01-12 16:11:46 +00:00 committed by GitHub
parent f4b651456c
commit d85643d5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ fn main() {
* If the slice starts at index 0, Rust’s range syntax means we can drop the starting index.
* The same is true for the last index, so `let s: &[i32] = &a[2..len];` or `let s: &[i32] = &a[2..];` are equal.
* The same is true for the last index, so `&a[2..a.len()]` and `&a[2..]` are equal.
* We set `s` as a reference of `i32`s. Notice that the type of `s` no longer has an array length. This avoids type errors when performing computations on slices of different sizes.