3 ms·
I use handles quite a bit in some rust code because you can't have self referential objects yet since rust does not have have immovable objects. While it felt
by the_mitsuhiko 8y ago
I use handles quite a bit in some rust code because you can't have self referential objects yet since rust does not have have immovable objects. While it felt like a huge hack in the beginning I really warmed up to the idea now.
- majewsky 8y agoUsing handles instead of proper references is still a huge hack IMO, because you lose all the soundness checks that the compiler can do for references. It's a good thing that immovable objects are coming soon.
- tomp 8y agoWhy can’t you just wrap handles into unique/referenced types?
- habitue 8y agoYou can, but that only solves part of the problem: keeping pointer types from being used as the wrong type. You still have the equivalent of use-after-free to guard against which the lifetime system tracks for you for pointers, but not for handles.
- the_mitsuhiko 8y agoYou can associate lifetimes with handles just fine.