You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/trpl/vectors.md
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,18 @@
1
1
% Vectors
2
2
3
3
A *vector* is a dynamic or "growable" array, implemented as the standard
4
-
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md) statement). Vectors always allocate their data on the heap. Vectors are to slices
5
-
what `String` is to `&str`. You can create them with the `vec!` macro:
4
+
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md)
5
+
statement). Vectors always allocate their data on the heap. Vectors are to
6
+
[slices][slices] what [`String`][string] is to `&str`. You can
7
+
create them with the `vec!` macro:
6
8
7
9
```{rust}
8
10
let v = vec![1, 2, 3]; // v: Vec<i32>
9
11
```
10
12
13
+
[slices]: primitive-types.html#slices
14
+
[string]: strings.html
15
+
11
16
(Notice that unlike the `println!` macro we've used in the past, we use square
12
17
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
0 commit comments