std-method

Iterator::skip

Discard the first n items when the adapter is driven, then yield subsequent ones. This is not a general constant-time seek. Expected stdout (not executed): [4, 5] Common mistake: Assuming skip is always free for arbitrary iterators.

Formal Syntax & Structure

rust syntaxrust
fn skip(self, n: usize) -> Skip<Self> where Self: Sized

Working Example

Example Snippetrust
fn main() {    let page: Vec<_> = (1..8).skip(3).take(2).collect();    println!("{page:?}");}
Rust Reference