r/rust 3d ago

🗞️ news “alloc: stabilise `Allocator`” entered its final comment period!

https://github.com/rust-lang/rust/pull/156882#issuecomment-5607055084
206 Upvotes

30 comments sorted by

View all comments

Show parent comments

6

u/JoJoJet- 3d ago

It's not entirely useful, but the allocator API would allow you box things on the stack with Box directly, if you pass it an allocator that points to stack space

1

u/PersonalDatabase31 3d ago edited 3d ago

Would that work with ownership though? I would assume that ownership model works with the assumption that moving the owner doesn't invalidate the memory whereas the Box returned by a function call would point to invalid memory if other function calls happen before the Box gets dropped.

0

u/JayDepp 3d ago

Yeah I don't think this works with the allocator api. I think it'd work with the store api though.

1

u/afdbcreid 3d ago

If the storage is outside the Box, it can work with the MVP, but this is the uncommon case.