Re: [PATCH v2 2/3] rust: kernel: implement iterators for ScatterList

From: Martin Rodriguez Reboredo
Date: Fri Jun 02 2023 - 16:47:38 EST


On 6/2/23 07:18, Qingsong Chen wrote:
ScatterList could be transmuted from raw pointers of a valid
`sg_table`. Then we can use those iterators to access the
following normal entries.

Signed-off-by: Qingsong Chen <changxian.cqs@xxxxxxxxxxxx>
---
[...]
+ /// Get an iterator for immutable references.
+ pub fn iter(&self) -> Iter<'_> {
+ Iter(ScatterList::as_ref(self.opaque.get()))
+ }
+
+ /// Get an iterator for mutable references.
+ pub fn iter_mut(&mut self) -> IterMut<'_> {
+ IterMut(ScatterList::as_mut(self.opaque.get()))
+ }

Per the previous commit, because both methods are unsafe you should put
the `SAFETY` comment on them.

+}
+
[...]