/// Pop an element from the front of the list
Pop an element from the front of the list
Pop an element from the front of the list
fn pop_front(&mut self) -> Option<Arc<Node<T, W>>> {
        if self.head.is_null() {
            // The list is empty
            return None;
        }
        self.len -= 1;
        unsafe {
            // Convert the ptr to Arc<_>
            let node = ptr2arc(self.head);
            // Update the head pointer
            self.head = *node.next_all.get();
            // If the pointer is null, then the list is empty
            if self.head.is_null() {
                self.tail = ptr::null_mut();
            } else {
                *(*self.head).prev_all.get() = ptr::null_mut();
            }
            Some(node)
        }
    }
fn pop_front ( & mut self ) -> Option < Arc < Node < T , W > > > { if self . head . is_null ( ) { // The list is empty return None ; } self . len -= 1 ; unsafe { // Convert the ptr to Arc<_> let node = ptr2arc ( self . head ) ; // Update the head pointer self . head = * node . next_all . get ( ) ; // If the pointer is null, then the list is empty if self . head . is_null ( ) { self . tail = ptr :: null_mut ( ) ; } else { * ( * self . head ) . prev_all . get ( ) = ptr :: null_mut ( ) ; } Some ( node ) } }
Pop an element from the front of the list
Pop an element from the front of the list
&mut self