Hi Alex,

(I agree with all the suggestions, I will reply to the ones where I have
comments in a few emails if that's Ok.).

Replied to one below:

On 11/23/2025 10:47 PM, Alexandre Courbot wrote:
>> +    }
>> +
>> +    /// Check if this node is linked in a list (not isolated).
>> +    #[inline]
>> +    pub fn is_in_list(&self) -> bool {
>> +        // SAFETY: self.as_raw() is valid per type invariants.
>> +        unsafe {
>> +            let raw = self.as_raw();
>> +            (*raw).next != raw && (*raw).prev != raw
>> +        }
>> +    }
>> +
>> +    /// Check if the list is empty.
>> +    #[inline]
>> +    pub fn is_empty(&self) -> bool {
>> +        // SAFETY: self.as_raw() is valid per type invariants.
>> +        unsafe {
>> +            let raw = self.as_raw();
>> +            (*raw).next == raw
>> +        }
>> +    }
>
> Does this method also apply to non-sentinel nodes? If not, should we
> move it to `Clist`?

Yes it does, will move it.

> 
> I am also wondering what the difference is with `is_in_list`. If
> `raw.next == raw`, then on a valid list `raw.prev == raw` as well, so
> it seems to be that `is_in_list()` is equivalent to `!is_empty()`.

Yes, this is a good thing for me to refactor. We can keep is_in_list() in
ClistHead and move ClistHead::Empty() to Clist. Though I would probably directly
compare the pointers instead of calling is_in_list() because it seems weird to
check with a sentinel list_head about whether it is in the list :) After all, it
IS the list :-D. I will rearrange it, thanks for the suggestion!

 - Joel

Reply via email to