aboutsummaryrefslogtreecommitdiff
path: root/rust/kernel/alloc.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <[email protected]>2024-10-04 17:41:21 +0200
committerMiguel Ojeda <[email protected]>2024-10-15 23:10:32 +0200
commit1d1d223aa3b37c34271aefc2706340d0843bfcb2 (patch)
tree9846f4ed7c0058e53ec1b5d785385e1a11a35dd2 /rust/kernel/alloc.rs
parent2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6 (diff)
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 <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed typos. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Diffstat (limited to 'rust/kernel/alloc.rs')
-rw-r--r--rust/kernel/alloc.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
index 7f654b214ec2..86d2077a8e64 100644
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@ -20,6 +20,7 @@ pub use self::kbox::KBox;
pub use self::kbox::KVBox;
pub use self::kbox::VBox;
+pub use self::kvec::IntoIter;
pub use self::kvec::KVVec;
pub use self::kvec::KVec;
pub use self::kvec::VVec;