[Pre-RFC] Two new structures for two different types of memory

Taken from the RFC:

This RFC proposes the creation of two types of primitive "growable" structures that manages different types of memories and can be seen as an alternative for alloc::vec::Vec<T>, the built-in structure that manages heap-allocated memory.

  1. A vector for stack-based allocations.
  2. Hydric approach between heap and stack memory.

This proposal is a bit controversial and my instinct says it won't go too far, that is why I didn't put a lot of content. Well, tell me what you guys think about it -> https://github.com/c410-f3r/rfcs/pull/1

Personally, I'd rather see a good Sized container for unsized types. That should be a reasonable primitive to build this sort of thing on top of, and many others. If that were called StackSlot<T>, making one that overflows onto the stack is just an enum with a Box variant and a StackSlot variant. It could also open the way for unsized structs to be more useful.

On the other hand, I don't tend to hang around the internals forum, so I don't have a good idea how they would react.

I think the smallvec crate already does this, at least for allocations up to a certain size. It falls back to heap allocation for sizes larger than the cutoff.

I'm not sure how moisture relates to data structures and their allocation on the stack or on the heap?

This is better suited for internals.rust-lang.org.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.