std-method
LinkedList::pop_front
Remove the first item and transfer its ownership to the caller. Return None if no item remains. Expected stdout (not executed): Some("a") Some("b") Common mistake: Keeping an active shared reference to the first element while removing it.
Formal Syntax & Structure
rust syntaxrust
fn pop_front(&mut self) -> Option<T>Working Example
Example Snippetrust
fn main() { use std::collections::LinkedList; let mut q = LinkedList::from(["a", "b"]); println!("{:?}", q.pop_front()); println!("{:?}", q.front());}