summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2025-06-10 10:31:56 +0000
committerDanilo Krummrich <dakr@kernel.org>2025-06-11 16:35:10 +0200
commit47d8101924b58e03bfd065c972172e6b69331397 (patch)
treed8ea2a1c549e0ab1760d4713a23306c85ab9b267 /rust/kernel/alloc
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494 (diff)
rust: vec: impl Default for Vec with any allocator
The implementation of Default is restricted to only work with kmalloc vectors for no good reason. This means I have to use mem::replace(&mut my_vec, KVVec::new()) in Rust Binder instead of `mem::take(&mut my_vec)`. Thus, expand the impl of Default to work with any allocator including kvmalloc. Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://lore.kernel.org/r/20250610-vec-default-v1-1-7bb2c97d75a0@google.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/alloc')
-rw-r--r--rust/kernel/alloc/kvec.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs
index 1a0dd852a468..606616fc0e59 100644
--- a/rust/kernel/alloc/kvec.rs
+++ b/rust/kernel/alloc/kvec.rs
@@ -851,7 +851,7 @@ where
}
}
-impl<T> Default for KVec<T> {
+impl<T, A: Allocator> Default for Vec<T, A> {
#[inline]
fn default() -> Self {
Self::new()