std-method

VecDeque::rotate_left

Move the first mid elements to the back in their original order. The rotation count must not exceed len. Useful for round-robin scheduling. Expected stdout (not executed): ["C", "A", "B"] Common mistake: Treating a count greater than len as automatically reduced modulo len.

Formal Syntax & Structure

rust syntaxrust
pub fn rotate_left(&mut self, mid: usize)

Working Example

Example Snippetrust
fn main() {    use std::collections::VecDeque;    let mut workers = VecDeque::from(["A", "B", "C"]);    workers.rotate_left(2);    println!("{workers:?}");}
Rust Reference