Skip to content

Commit

Permalink
Merge pull request #195 from japm48/patch-1
Browse files Browse the repository at this point in the history
Lifetimes: explain how to fix destructor example
  • Loading branch information
Centril committed Feb 2, 2020
2 parents 37b6170 + 0fd7306 commit 98d750a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ data.push(4);
// Here, the destructor is run and therefore this'll fail to compile.
```

One way to convince the compiler that `x` is no longer valid is by using `drop(x)` before `data.push(4)`.

Furthermore, there might be multiple possible last uses of the borrow, for
example in each branch of a condition.

Expand Down

0 comments on commit 98d750a

Please sign in to comment.