std-method
LinkedList::front_mut
Borrow the first element mutably, allowing an in-place update without changing sequence length. Expected stdout (not executed): Some(14) Common mistake: Expecting front_mut to insert into an empty list.
Formal Syntax & Structure
rust syntaxrust
fn front_mut(&mut self) -> Option<&mut T>Working Example
Example Snippetrust
fn main() { use std::collections::LinkedList; let mut q = LinkedList::from([4, 7]); if let Some(first) = q.front_mut() { *first += 10; } println!("{:?}", q.front());}