linux/rust/kernel/alloc
Alexandre Courbot c09a8ac1cd rust: alloc: implement Borrow and BorrowMut for Vec
Implement `Borrow<[T]>` and `BorrowMut<[T]>` for `Vec<T>`. This allows
`Vec<T>` to be used in generic APIs asking for types implementing those
traits. `[T; N]` and `&mut [T]` also implement those traits allowing
users to use either owned, borrowed and heap-owned values.

The implementation leverages `as_slice` and `as_mut_slice`.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250616-borrow_impls-v4-1-36f9beb3fe6a@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-06-18 23:09:21 +02:00
..
kvec rust: alloc: add Vec::insert_within_capacity 2025-05-07 18:40:45 +02:00
allocator.rs rust: alloc: make ReallocFunc::call inline 2025-03-06 20:49:06 +01:00
allocator_test.rs rust: alloc: add missing Markdown code span 2025-05-25 22:58:35 +02:00
kbox.rs Alloc changes for v6.16 2025-05-18 20:56:03 +02:00
kvec.rs rust: alloc: implement Borrow and BorrowMut for Vec 2025-06-18 23:09:21 +02:00
layout.rs rust: alloc: add doctest for ArrayLayout::new() 2025-01-13 23:45:30 +01:00