Merge pull request #195 from japm48/patch-1

Lifetimes: explain how to fix destructor example
pull/200/head
Mazdak Farrokhzad 5 years ago committed by GitHub
commit 98d750ac06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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.

Loading…
Cancel
Save