pub fn iter_for_each(
src: &Value,
f: impl FnMut(Value, usize) -> Result<(), String>,
) -> Result<(), String>Expand description
Drive an iterator object (one with a .next() returning {value, done}) to
exhaustion.
Step src’s iterator, handing each value to f, and CLOSE the iterator if
f exits abruptly (7.4.9 IteratorClose).
The difference from iter_all + a loop is that this never materializes the
whole sequence: Array.from(infinite, mapFn) where mapFn throws has to
stop at the first call, and draining first means it never gets there at all.