Skip to content

Commit bc6318d

Browse files
committed
Auto merge of #25676 - dmgawel:patch-1, r=huonw
Earlier created vector `["Hello", "world"]` has two elements and we try to add a third element.
2 parents 7bd3bbd + e30c6d1 commit bc6318d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/doc/trpl/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ of those times. As the error explains, while we made our binding mutable, we
150150
still cannot call `push`. This is because we already have a reference to an
151151
element of the vector, `y`. Mutating something while another reference exists
152152
is dangerous, because we may invalidate the reference. In this specific case,
153-
when we create the vector, we may have only allocated space for three elements.
154-
Adding a fourth would mean allocating a new chunk of memory for all those elements,
153+
when we create the vector, we may have only allocated space for two elements.
154+
Adding a third would mean allocating a new chunk of memory for all those elements,
155155
copying the old values over, and updating the internal pointer to that memory.
156156
That all works just fine. The problem is that `y` wouldn’t get updated, and so
157157
we’d have a ‘dangling pointer’. That’s bad. Any use of `y` would be an error in

0 commit comments

Comments
 (0)