Skip to content

Commit 8b51b8f

Browse files
committed
Rollup merge of rust-lang#26789 - tshepang:improve-array-examples, r=alexcrichton
2 parents 2e78d37 + f82276d commit 8b51b8f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/doc/reference.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,12 +3351,17 @@ heap.
33513351
A slice is a 'view' into an array. It doesn't own the data it points
33523352
to, it borrows it.
33533353

3354-
An example of each kind:
3354+
Examples:
33553355

33563356
```{rust}
3357-
let vec: Vec<i32> = vec![1, 2, 3];
3358-
let arr: [i32; 3] = [1, 2, 3];
3359-
let s: &[i32] = &vec[..];
3357+
// A stack-allocated array
3358+
let array: [i32; 3] = [1, 2, 3];
3359+
3360+
// A heap-allocated array
3361+
let vector: Vec<i32> = vec![1, 2, 3];
3362+
3363+
// A slice into an array
3364+
let slice: &[i32] = &vector[..];
33603365
```
33613366

33623367
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The

0 commit comments

Comments
 (0)