Removes the first element from the list and returns it, or None if empty.
(&mut self)
| 203 | |
| 204 | /// Removes the first element from the list and returns it, or None if empty. |
| 205 | pub fn pop_front(&mut self) -> Option<L::Handle> { |
| 206 | let head = self.head?; |
| 207 | unsafe { |
| 208 | self.head = L::pointers(head).as_ref().get_next(); |
| 209 | if let Some(new_head) = self.head { |
| 210 | L::pointers(new_head).as_mut().set_prev(None); |
| 211 | } |
| 212 | L::pointers(head).as_mut().set_next(None); |
| 213 | L::pointers(head).as_mut().set_prev(None); |
| 214 | Some(L::from_raw(head)) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | /// Returns whether the linked list does not contain any node |
| 219 | pub const fn is_empty(&self) -> bool { |