Re: [PATCH] rust/alloc: add Vec::into_boxed_slice()

From: Danilo Krummrich

Date: Thu Mar 26 2026 - 07:08:36 EST


On Thu Mar 26, 2026 at 11:45 AM CET, David Rheinsberg wrote:
> On Thu, Mar 26, 2026, at 11:33 AM, Alice Ryhl wrote:
>> We currently say that you should provide the right length when freeing
>> an allocation, but this is going to violate that. You should probably
>> invoke realloc here, like stdlib does.

Ok, Alice was faster. :)

> `std` calls `shrink_to_fit()`. Should I add it as well? How about
> `shrink_to()`? I don't particularly need them, but I can expose them as well,
> given that I would have to implement those.

Let's stick to A::realloc(), that's the only thing we need to justify the safety
requirement. I don't want to rely on shrink_to() and shrink_to_fit() not doing
additional things we don't need for this conversion.