fn main() {
fn f<T>(_: T) {}
let f = f;
let v = 0;
f(&v);
}
Error message:-
error[E0597]: `v` does not live long enough
--> src/main.rs:6:1
|
5 | f(&v);
| - borrow occurs here
6 | }
| ^ `v` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: aborting due to previous error
error: Could not compile `playground`.
Found this open issue in GitHub pointing to above error. Is there any workaround available for this issue?
error[E0597]: `group` does not live long enough
--> src/main.rs:61:1
|
59 | let res = group.layout();
| ----- borrow occurs here
60 | res.draw();
61 | }
| ^ `group` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error: aborting due to previous error
This is different - layout is saying it needs to borrow &self (the group) for 'a which is actually the lifetime of element here. Since group is dropped before element the compiler complains.
Can u please share your revised version the this Element/Group sample? I'm a rust newbie and am just struggling with the lifetime parameters. Hope this can help me understand this idea better. Thanks