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

From: Alice Ryhl
Date: Thu Aug 01 2024 - 05:03:40 EST


On Thu, Aug 1, 2024 at 11:00 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> 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>

(We may prefer to pick this from Benno's series:
https://lore.kernel.org/rust-for-linux/20240708205325.1275473-1-benno.lossin@xxxxxxxxx/
)