Avatar ·

Does Rust have queue and stack collections?

Hello everyone! I recently started learning Rust, and I have a question about data structures. In other languages (e.g., C++ or Python), there are built-in queues and stacks. I tried to find something similar in Rust's standard library, but I haven't figured it out yet. Here's what I tried: I want to write a program that processes tasks in the order they arrive (FIFO). I created a vector and used `push` to add items, and for extracting the first element, I tried using `remove(0)`, but the compiler complains about performance. Here's an example: ```rust fn main() { let mut queue: Vec = Vec::new(); queue.push(1); queue.push(2); queue.push(3); // Trying to extract the first element let first = queue.remove(0); println!("{}", first); } ``` This works, but I