Commit 1e01dcf3 authored by Alice Ryhl's avatar Alice Ryhl Committed by Matthew Maurer
Browse files

FROMGIT: rust: alloc: add Vec::drain_all



This is like the stdlib method drain, except that it's hard-coded to use
the entire vector's range. Rust Binder uses it in the range allocator to
take ownership of everything in a vector in a case where reusing the
vector is desirable.

Implementing `DrainAll` in terms of `slice::IterMut` lets us reuse some
nice optimizations in core for the case where T is a ZST.

Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarBenno Lossin <lossin@kernel.org>
Link: https://lore.kernel.org/r/20250502-vec-methods-v5-4-06d20ad9366f@google.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>

Bug: 414994413
(cherry picked from commit 088bf14a
 https://github.com/Rust-for-Linux/linux.git

 alloc-next)
Change-Id: I65ab0823980a15a0c18f960f9ab7ff6fa621c06a
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
parent 1a17ca09
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment