From 0fd7306f5a323c1e5b38ada457e84a39785cb298 Mon Sep 17 00:00:00 2001 From: japm48 Date: Sun, 2 Feb 2020 00:56:41 +0100 Subject: [PATCH] Lifetimes: explain how to fix destructor example --- src/lifetimes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lifetimes.md b/src/lifetimes.md index bc917b14..649cd770 100644 --- a/src/lifetimes.md +++ b/src/lifetimes.md @@ -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.