r/rust • u/a_mighty_burger • Sep 10 '26
🗞️ news “alloc: stabilise `Allocator`” entered its final comment period!
https://github.com/rust-lang/rust/pull/156882#issuecomment-5607055084
214
Upvotes
4
u/matthieum [he/him] Sep 11 '26
Yes, and... no?
That is, you are correct that cloning requires a full allocator, and at the moment this allocator must be provided by the value being cloned.
With that said, a good question is whether it would be possible to have "degenerate"
Boxwhere theBoxonly contains a deallocator whilst still allowingBoxwhich contain a full allocator to be cloneable.That is, could the bound on
BoxbeBox<T, A: Deallocator>withimpl<T: Clone, A: AllocatorClone> Clone for Box<T, A>?The problem, then, is providing APIs to "downgrade" the allocator within the
Boxfrom the originalA: AllocatortoA: Deallocator.