Hacker News new | ask | show | jobs
by hgs3 1093 days 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.
1 comments

You 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.
Sure, 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.