Re: [PATCH v6 1/6] rust: kernel: add `drop_contents` to `BoxExt`

From: Alice Ryhl
Date: Tue Jul 23 2024 - 05:15:48 EST


On Thu, Jul 11, 2024 at 6:21 PM Matt Gilbride <mattgilbride@xxxxxxxxxx> wrote:
>
> From: Benno Lossin <benno.lossin@xxxxxxxxx>
>
> Sometimes (see [1]) it is necessary to drop the value inside of a
> `Box<T>`, but retain the allocation. For example to reuse the allocation
> in the future.
> Introduce a new function `drop_contents` that turns a `Box<T>` into
> `Box<MaybeUninit<T>>` by dropping the value.
>
> Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
> Link: https://lore.kernel.org/rust-for-linux/20240418-b4-rbtree-v3-5-323e134390ce@xxxxxxxxxx/ [1]

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>