Lifetimes: explain how to fix destructor example

pull/195/head
japm48 5 years ago committed by GitHub
parent 37b6170db8
commit 0fd7306f5a
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. // 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 Furthermore, there might be multiple possible last uses of the borrow, for
example in each branch of a condition. example in each branch of a condition.

Loading…
Cancel
Save