Skip to content

Commit 5e96da3

Browse files
committed
Rollup merge of rust-lang#31563 - SDX2000:docfixes1, r=steveklabnik
This is a minor change. Please see title. IMO this is important since this is the first instance when we talk about allocating a vector. Not saying that it is allocated on the stack here leaves room for speculation and this might put off some people (they might not even read the later sections which go into more detail about this).
2 parents 3369665 + 8f61a4b commit 5e96da3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/doc/book/ownership.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ fn foo() {
5151
}
5252
```
5353

54-
When `v` comes into scope, a new [vector] is created, and it allocates space on
55-
[the heap][heap] for each of its elements. When `v` goes out of scope at the
56-
end of `foo()`, Rust will clean up everything related to the vector, even the
57-
heap-allocated memory. This happens deterministically, at the end of the scope.
54+
When `v` comes into scope, a new [vector] is created on [the stack][stack],
55+
and it allocates space on [the heap][heap] for its elements. When `v` goes out
56+
of scope at the end of `foo()`, Rust will clean up everything related to the
57+
vector, even the heap-allocated memory. This happens deterministically, at the
58+
end of the scope.
5859

5960
We'll cover [vectors] in detail later in this chapter; we only use them
6061
here as an example of a type that allocates space on the heap at runtime. They
@@ -67,6 +68,7 @@ Vectors have a [generic type][generics] `Vec<T>`, so in this example `v` will ha
6768
[arrays]: primitive-types.html#arrays
6869
[vectors]: vectors.html
6970
[heap]: the-stack-and-the-heap.html
71+
[stack]: the-stack-and-the-heap.html#the-stack
7072
[bindings]: variable-bindings.html
7173
[generics]: generics.html
7274

0 commit comments

Comments
 (0)