Box::leak is defined as
unsafe { &mut *Box::into_raw(b) }
However, there is no way to extract the allocator while leaking without using the underlying Box::into_raw_with_allocator, which returns (*mut T, A). I propose adding Box::leak_with_allocator, which returns (&mut T, A) by calling into_raw_with_allocator and performing the unsafe cast.
Any thoughts on this? Happy to make a PR if this is something that others think is a good idea.
Box::leak is defined as
However, there is no way to extract the allocator while leaking without using the underlying
Box::into_raw_with_allocator, which returns(*mut T, A). I propose addingBox::leak_with_allocator, which returns(&mut T, A)by callinginto_raw_with_allocatorand performing the unsafe cast.Any thoughts on this? Happy to make a PR if this is something that others think is a good idea.