std-method
Vec::remove
Remove the indexed value and close the gap, preserving the relative order of remaining items. An invalid index panics. Shifting the suffix takes linear time in its length. Expected stdout (not executed): cancel ["read", "write"] Common mistake: Using repeated remove(0) for a large FIFO queue instead of VecDeque.
Formal Syntax & Structure
rust syntaxrust
pub fn remove(&mut self, index: usize) -> TWorking Example
Example Snippetrust
fn main() { let mut tasks = vec!["read", "cancel", "write"]; let gone = tasks.remove(1); println!("{gone} {tasks:?}");}