Skip to content

Commit 98d750a

Browse files
authored
Merge pull request #195 from japm48/patch-1
Lifetimes: explain how to fix destructor example
2 parents 37b6170 + 0fd7306 commit 98d750a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/lifetimes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ data.push(4);
261261
// Here, the destructor is run and therefore this'll fail to compile.
262262
```
263263

264+
One way to convince the compiler that `x` is no longer valid is by using `drop(x)` before `data.push(4)`.
265+
264266
Furthermore, there might be multiple possible last uses of the borrow, for
265267
example in each branch of a condition.
266268

0 commit comments

Comments
 (0)