You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustc 1.14.0 (e8a0123 2016-12-16)
error: o does not live long enough
--> :13:17
|
13 | o.get().as_ref().ok_or_else(|| panic!())
| ^ does not live long enough
...
19 | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the anonymous lifetime #1 defined on the block at 10:52...
--> :10:53
|
10 | fn lookup(&mut self, s: String) -> Result<&u32> {
| ^
It appears that OccupiedEntry::get is returning a reference to the value in the HashMap with the lifetime of the Entry, not the HashMap. This seems like a bug to me.
The text was updated successfully, but these errors were encountered:
Consider the following toy code to implement a simple
HashMap
-based cache.The borrow checker will fail this.
It appears that
OccupiedEntry::get
is returning a reference to the value in theHashMap
with the lifetime of theEntry
, not theHashMap
. This seems like a bug to me.The text was updated successfully, but these errors were encountered: