]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #24665: sw17ch/document-complete-slice-syntax
authorAlex Crichton <alex@alexcrichton.com>
Tue, 21 Apr 2015 22:23:15 +0000 (15:23 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 21 Apr 2015 22:23:15 +0000 (15:23 -0700)
The documentation doesn't appear to describe the `&foo[..]` syntax.

I tried looking in `primitive-types.html#slices` and `std/primitive.slice.html`.

There's an example of partially slicing an array in trpl and a mention of `&foo[..]` in [the standard library documentation](https://doc.rust-lang.org/std/primitive.slice.html), but neither place, from what I can see, actually describes the behavior of `&foo[..]`.

+r? @steveklabnik

src/doc/trpl/primitive-types.md

index 811080cd50987ea542df4a2e516119801c0358ff..e4af03869d1d85e2c9e0c976b900f9acb0715a21 100644 (file)
@@ -168,6 +168,7 @@ like arrays:
 ```rust
 let a = [0, 1, 2, 3, 4];
 let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
+let complete = &a[..]; // A slice containing all of the elements in a
 ```
 
 Slices have type `&[T]`. We’ll talk about that `T` when we cover