On Fri Feb 20, 2026 at 12:29 AM JST, Joel Fernandes wrote:
<snip>
>> > + pub unsafe fn from_raw<'a>(ptr: *mut bindings::list_head) -> &'a Self
>> > {
>> > + // SAFETY:
>> > + // - [`CList`] has same layout as [`CListHead`] due to
>> > repr(transparent).
>> > + // - Caller guarantees `ptr` is a valid, sentinel `list_head`
>> > object.
>> > + unsafe { &*ptr.cast() }
>> > + }
>>
>> IIUC you can call `CListHead::from_raw` here instead of repeating its
>> code.
>
> CListHead::from_raw returns &CListHead, but we need &CList<T, OFFSET>.
> Since CList is repr(transparent) over CListHead, the direct ptr.cast()
> is the correct approach - we'd need an additional cast after
> CListHead::from_raw anyway, which would be more code, not less.
Ah, in that case that works, yes.
>> > + fn next(&mut self) -> Option<Self::Item> {
>>
>> This method is the only one not marked `#[inline]`.
>
> Added #[inline], thanks for catching that.
>
>> > +impl<'a> FusedIterator for CListHeadIter<'a> {}
>>
>> I asked this a couple of times ([1], [2]) but got no reply, so let me
>> try again. :) Given that `list_head` is doubly-linked, can we also
>> implement `DoubleEndedIterator`?
>
> Apologies for the missed replies! Yes, DoubleEndedIterator makes sense
> for doubly-linked lists. I'll add it as a follow-up patch since it
> requires a prev() method and some additional iterator state tracking.
Mmm, I expected (without trying) that it would be trivial, but if it
requires big changes to the iterator then let's consider that as a
follow-up indeed to avoid delaying this series further.