Skip to content

Commit

Permalink
Rollup merge of rust-lang#31563 - SDX2000:docfixes1, r=steveklabnik
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Manishearth committed Feb 13, 2016
2 parents 302e5cb + 8f61a4b commit 1598995
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/doc/book/ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ fn foo() {
}
```

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

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

Expand Down

0 comments on commit 1598995

Please sign in to comment.