std-method

VecDeque::push_front

Insert at the logical front. Existing elements remain in their relative order. This can represent an explicitly prioritized job. Expected stdout (not executed): ["urgent", "normal", "later"] Common mistake: Assuming insertion at the front preserves FIFO arrival order.

Formal Syntax & Structure

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

Working Example

Example Snippetrust
fn main() {    use std::collections::VecDeque;    let mut q = VecDeque::from(["normal", "later"]);    q.push_front("urgent");    println!("{q:?}");}
Rust Reference