Re:Why is Rust difficult?
by pmarcelll on Monday January 22, 2018 @11:23AM
(#16205552)
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.
[ Parent
| on HN ]
The 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-non...