std-method

slice::rotate_left

Move the first mid elements to the end while maintaining relative order inside both parts. The amount may equal the length, but not exceed it. Expected stdout (not executed): ["Tue", "Wed", "Thu", "Mon"] Common mistake: Assuming an arbitrary large shift is reduced modulo length automatically.

Formal Syntax & Structure

rust syntaxrust
slice.rotate_left(mid)

Working Example

Example Snippetrust
fn main() {    let mut shifts = ["Mon", "Tue", "Wed", "Thu"];    shifts.rotate_left(1);    println!("{shifts:?}");}
Rust Reference