Skip to content
masterclass Buddy

Rust · Method

Iterator::collect

Iterator::collect consumes an iterator and builds a value such as Vec, VecDeque, or a custom type implementing FromIterator. The result type must be inferable or stated explicitly.

Last updated

Since
1.0.0

Syntax

fn collect<B>(self) -> B where Self: Iterator, B: FromIterator<Self::Item>;

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • FromIterator
  • IntoIterator
  • Vec
  • VecDeque

Source: FromIterator in core::iter - Rust. Checked 2026-11-03.