mirror_ubuntu-kernels/rust/kernel/alloc
Danilo Krummrich 1d1d223aa3 rust: alloc: implement IntoIterator for Vec
Implement `IntoIterator` for `Vec`, `Vec`'s `IntoIter` type, as well as
`Iterator` for `IntoIter`.

`Vec::into_iter` disassembles the `Vec` into its raw parts; additionally,
`IntoIter` keeps track of a separate pointer, which is incremented
correspondingly as the iterator advances, while the length, or the count
of elements, is decremented.

This also means that `IntoIter` takes the ownership of the backing
buffer and is responsible to drop the remaining elements and free the
backing buffer, if it's dropped.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20241004154149.93856-18-dakr@kernel.org
[ Fixed typos. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-10-15 23:10:32 +02:00
..
allocator_test.rs rust: alloc: implement KVmalloc allocator 2024-10-15 22:56:59 +02:00
allocator.rs rust: alloc: implement KVmalloc allocator 2024-10-15 22:56:59 +02:00
kbox.rs rust: alloc: implement kernel Box 2024-10-15 22:56:59 +02:00
kvec.rs rust: alloc: implement IntoIterator for Vec 2024-10-15 23:10:32 +02:00
layout.rs rust: alloc: introduce ArrayLayout 2024-10-15 22:56:59 +02:00
vec_ext.rs rust: avoid unused import warning in rusttest 2024-06-11 23:33:28 +02:00