2 ms·
collect calls FromIterator, so: let five_fives = std::iter::repeat(5).take(5); // this: let v: Vec<i32> = five_fives.collect(); // is equivalent to t
by steveklabnik 5y ago
collect calls FromIterator, so:
let five_fives = std::iter::repeat(5).take(5);
// this:
let v: Vec<i32> = five_fives.collect();
// is equivalent to this
use std::iter::FromIterator;
let v = Vec::from_iter(five_fives);
if you prefer a function-like form.