Thursday, January 9, 2020

What types are heap-allocated in Rust

Today I stumbled on this question regarding which standard Rust types do alloc in the heap. I have this question popping in my head quite often, so here are the heap-allocated ones:

  • Box, simple heap allocation;
  • Rc, reference counter;
  • Arc, thread-safe atomic reference counter;
  • collections.

Reference to the answer can be found here.

No comments: