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

From: Alice Ryhl
Date: Thu Aug 01 2024 - 05:00:53 EST


On Sat, Jul 27, 2024 at 10:30 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>