#Borrow Checker and lifetime issues with state in UI framework

2 messages · Page 1 of 1 (latest)

quick rose
#

My state is a Vec<usize>. All my widgets need a immutable reference to my state and that works fine. I also need a callback that can mutate the Vec. I was trying to give the callback ownership of the vec because I do not use it anywhere else but the problem that the callback closure does not live long enough. My vec needs to live as long the main thread, but when I move the vec to closure, the lifetime is not long enough. Is there a way to extend to lifetime but still give mutable access to my closure and immutable acesss to my widgets?

#

Borrow Checker and lifetime issues with state in UI framework