diff options
| author | dmgawel <dgkonik@gmail.com> | 2015-05-21 14:30:32 +0200 |
|---|---|---|
| committer | dmgawel <dgkonik@gmail.com> | 2015-05-21 14:30:32 +0200 |
| commit | e30c6d131f8a0cd49fd57c263e16f6734f27bbd3 (patch) | |
| tree | 5eec720fdce0133cf82d70adc2b9881b7f57367b /src | |
| parent | 7bd3bbd78e24f640754ccd223611d1ef412a6106 (diff) | |
| download | rust-e30c6d131f8a0cd49fd57c263e16f6734f27bbd3.tar.gz rust-e30c6d131f8a0cd49fd57c263e16f6734f27bbd3.zip | |
Introduction vector example elements counting fix
Earlier created vector `["Hello", "world"]` has two elements and we try to add a third element.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/trpl/README.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doc/trpl/README.md b/src/doc/trpl/README.md index 9ca5de2b50a..d7f810dd857 100644 --- a/src/doc/trpl/README.md +++ b/src/doc/trpl/README.md @@ -150,8 +150,8 @@ of those times. As the error explains, while we made our binding mutable, we still cannot call `push`. This is because we already have a reference to an element of the vector, `y`. Mutating something while another reference exists is dangerous, because we may invalidate the reference. In this specific case, -when we create the vector, we may have only allocated space for three elements. -Adding a fourth would mean allocating a new chunk of memory for all those elements, +when we create the vector, we may have only allocated space for two elements. +Adding a third would mean allocating a new chunk of memory for all those elements, copying the old values over, and updating the internal pointer to that memory. That all works just fine. The problem is that `y` wouldn’t get updated, and so we’d have a ‘dangling pointer’. That’s bad. Any use of `y` would be an error in |
