linux-next/rust/kernel/alloc
Benno Lossin 01db99b272 rust: kernel: add drop_contents to BoxExt
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.

Link: https://lore.kernel.org/rust-for-linux/20240418-b4-rbtree-v3-5-323e134390ce@google.com/ [1]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20240819112415.99810-1-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-08-22 00:16:06 +02:00
..
allocator.rs slab, rust: extend kmalloc() alignment guarantees to remove Rust padding 2024-07-03 12:23:27 +02:00
box_ext.rs rust: kernel: add drop_contents to BoxExt 2024-08-22 00:16:06 +02:00
vec_ext.rs rust: avoid unused import warning in rusttest 2024-06-11 23:33:28 +02:00