Skip to content

Commit e3679e2

Browse files
authored
Merge pull request #1216 from Rosto75/master
Collection of fixes for the 'Vectors` chapter.
2 parents 2ce2a4b + 1ae475f commit e3679e2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/std/vec.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
Vectors are re-sizable arrays. Like slices, their size is not known at compile
44
time, but they can grow or shrink at any time. A vector is represented using
5-
3 words: a pointer to the data, its length, and its capacity. The capacity
6-
indicates how much memory is reserved for the vector. The vector can grow as
7-
long as the length is smaller than the capacity. When this threshold needs to
8-
be surpassed, the vector is reallocated with a larger capacity.
5+
3 parameters:
6+
- pointer to the data
7+
- length
8+
- capacity
9+
10+
The capacity indicates how much memory is reserved for the vector. The vector
11+
can grow as long as the length is smaller than the capacity. When this threshold
12+
needs to be surpassed, the vector is reallocated with a larger capacity.
913

1014
```rust,editable,ignore,mdbook-runnable
1115
fn main() {
@@ -26,8 +30,8 @@ fn main() {
2630
collected_iterator.push(0);
2731
// FIXME ^ Comment out this line
2832
29-
// The `len` method yields the current size of the vector
30-
println!("Vector size: {}", xs.len());
33+
// The `len` method yields the number of elements currently stored in a vector
34+
println!("Vector length: {}", xs.len());
3135
3236
// Indexing is done using the square brackets (indexing starts at 0)
3337
println!("Second element: {}", xs[1]);

0 commit comments

Comments
 (0)