Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

push

Common on array-like structures.

#![allow(unused)]
fn main() {
// Copyright 2025 Google LLC
// SPDX-License-Identifier: Apache-2.0

impl<T> Vec<T> {
    fn push(&mut self, value: T);
}

impl<T> VecDeque<T> {
    fn push_back(&mut self, value: T);
    fn push_front(&mut self, value: T);
}
}
- Modifies a sequential collection by adding an element.
  • Takes self by mutable reference.