3 ms·
The quoted sentence is not true, but most practical callbacks will create multiple paths to objects via borrows. Or you can move your structs into closures (lik
by pmarcelll 9y ago
The quoted sentence is not true, but most practical callbacks will create multiple paths to objects via borrows. Or you can move your structs into closures (like in C++). But I think what you originally wrote (using callbacks without Rc/RefCell) is fundamentally hard. You have to guarantee somehow that the struct is still alive when you access it though the borrow in the callback, otherwise you have a memory safety problem.
- pjmlp 9y agoThe situation I was having issues is explicitly acknowledged by the NLL RFC as being an issue. It is related to closure desugaring. https://github.com/nikomatsakis/nll-rfc/blob/master/0000-nonlexical-lifetimes.md https://github.com/nikomatsakis/nll-rfc/blob/master/0000-non...