4 ms·
All references in Rust must have an explicit owner. It's common to create additional structures whose entire purpose is to manage the lifetime of your actual da
by hgs3 3y ago
All references in Rust must have an explicit owner. It's common to create additional structures whose entire purpose is to manage the lifetime of your actual data structures. This means more memory consumption and potentially extra indirection, e.g. slot map handles vs pointers.
- kibwen 3y agoYou don't need heap allocations in order to have an explicit owner. Data on the stack is owned, and references to stack-allocated data can be handed out just fine.
- hgs3 3y agoSure, but you can't always use the stack. It has a limited amount of memory and doesn't handle dynamic data structures well, e.g. for a growable undirected graph you need auxiliary data structures for managing its nodes.