How to Use LinkedList in Rust (and Why You Probably Shouldn't)

Use Rust's LinkedList for O(1) end insertions, but prefer Vec or VecDeque for better performance and cache efficiency.

Use std::collections::LinkedList for constant-time insertion at both ends, but prefer Vec or VecDeque for better cache performance and memory efficiency in most cases.

use std::collections::LinkedList;

let mut list = LinkedList::new();
list.push_front(1);
list.push_back(2);
let first = list.pop_front(); // Some(1)

The standard library explicitly notes that array-based containers like Vec are generally faster and more memory-efficient because they make better use of CPU cache.