Skip to content

Commit 0e3c192

Browse files
Revised the paragraph about moving a vector (taking into account suggestions by echochamber).
1 parent 0051ac5 commit 0e3c192

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/doc/trpl/ownership.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ let v = vec![1, 2, 3];
121121
let v2 = v;
122122
```
123123

124-
The first line creates some data for the vector on the [stack][sh], `v`. The
125-
vector’s data, however, is stored on the [heap][sh], and so the vector contains a
126-
pointer to that data. When we move `v` to `v2`, it creates a copy of that pointer,
127-
for `v2`. Which would mean two pointers to the content of the vector on the
128-
heap. That would be a problem: it would violate Rust’s safety guarantees by
129-
introducing a data race. Therefore, Rust forbids using `v` after we’ve done the
130-
move.
124+
The first line allocates memory for the vector object, 'v', and for the data it
125+
contains. The vector object is stored on the [stack][sh] and contains a pointer
126+
to the content ([1, 2, 3]) stored on the [heap][sh]. When we move `v` to `v2`,
127+
it creates a copy of that pointer, for `v2`. Which means that there would be two
128+
pointers to the content of the vector on the heap. It would violate Rust’s
129+
safety guarantees by introducing a data race. Therefore, Rust forbids using `v`
130+
after we’ve done the move.
131131

132132
[sh]: the-stack-and-the-heap.html
133133

0 commit comments

Comments
 (0)