I am struggling to understand temporary lifetime concept in Rust.
Let's say I have the following struct with the Arc
field:
struct MyStruct {
arc_field: Arc<Mutex<i32>>,
}
When i try to access inner i32 field inside from the clone of the arc_field
it is complaining about
Temporary value dropped here while still borrowed
Here is how I am trying to retrieve it:
let my_field = my_struct.arc_field.clone().lock().unwrap();
Why is that I need to use let binding to increase it's lifetime?
Here is playground
Arc
? – Francis Gagné