std-method

LinkedList::push_front

Insert an owned item at the beginning of the sequence. Existing elements keep their relative order. Expected stdout (not executed): Some("plan") Common mistake: Expecting insertion at the back.

Formal Syntax & Structure

rust syntaxrust
fn push_front(&mut self, elt: T)

Working Example

Example Snippetrust
fn main() {    use std::collections::LinkedList;    let mut q = LinkedList::from(["review", "ship"]);    q.push_front("plan");    println!("{:?}", q.front());}
Rust Reference