pub fn iter_take(v: &Value, n: usize) -> Result<Vec<Value>, String>Expand description
Fully materialize any iterable into a vector of values.
Pull at most n values, then close the iterator — 8.6.2
IteratorBindingInitialization, which is what an array destructuring pattern
without a ...rest element performs.
The distinction from iter_all is not an optimization. A pattern names a
fixed number of targets, so the spec pulls exactly that many and calls
IteratorClose on whatever is left; draining instead made
const [first] = infiniteGenerator();run forever. It is also observable on any finite iterator, as the count of
next() calls and whether return() ever ran.
A ...rest element genuinely consumes the remainder, so those patterns keep
using iter_all and an unbounded source hangs there in node too.