feat: utils/linked_list: add is_empty

This commit is contained in:
Paul Pan 2024-08-29 20:41:52 +08:00
parent 9f4a804e30
commit 27fdf26cc1

View File

@ -65,6 +65,12 @@ impl<T: LinkHelper<ID>, const ID: usize> Link<T, ID> {
&*(container_of_offset!(self, T, T::LINK_OFFSET)) &*(container_of_offset!(self, T, T::LINK_OFFSET))
} }
pub fn is_empty(&self) -> bool {
debug_assert!(!(self.prev.is_none() && self.next.is_some()));
debug_assert!(!(self.prev.is_some() && self.next.is_none()));
self.prev.is_none() && self.next.is_none()
}
pub fn prev_raw(&self) -> &Option<AtomicPtr<T>> { pub fn prev_raw(&self) -> &Option<AtomicPtr<T>> {
&self.prev &self.prev
} }