On 2/6/2026 12:49 PM, Daniel Almeida wrote:
>> +#[repr(transparent)]
>> +pub(crate) struct CList<T, const OFFSET: usize>(CListHead, PhantomData<T>);
>> +
>> +impl<T, const OFFSET: usize> CList<T, OFFSET> {
>> + /// Create a typed [`CList`] reference from a raw sentinel `list_head`
>> pointer.
>> + ///
>> + /// # Safety
>> + ///
>> + /// - `ptr` must be a valid pointer to an allocated and initialized
>> `list_head` structure
>> + /// representing a list sentinel.
>> + /// - `ptr` must remain valid and unmodified for the lifetime `'a`.
>> + /// - The list must contain items where the `list_head` field is at
>> byte offset `OFFSET`.
>> + /// - `T` must be `#[repr(transparent)]` over the C struct.
>> + #[inline]
>> + pub(crate) 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() }
>> + }
>> +
>> + /// Check if the list is empty.
>> + #[inline]
>> + #[expect(dead_code)]
>> + pub(crate) fn is_empty(&self) -> bool {
>
> Why can’t this be pub?
I believe this was suggested by Gary. See the other thread where we are
discussing it (with Gary and Danilo) and let us discuss there.
--
Joel Fernandes