fn collect_coerced<U>(
container: &str,
len: usize,
iter: impl Iterator<Item = Result<U, SexpError>>,
) -> Result<Vec<U>, SexpError>Expand description
Drive a per-element coercion, batching every failure into one diagnostic.
Backs from_numeric_vec_with’s four SEXP-type branches: successes go into
the output Vec, failures accumulate as "invalid value at index <i>: <err>"
and are combined via BatchedErrors (matching the message grammar of the
Vec<T> arm of try_from_sexp_via_str_parse!). The per-element closure wraps
coercion failures as SexpError::InvalidValue; we unwrap that inner message
so the batched entry reads "...: value out of range" rather than the doubled
"...: invalid value: value out of range" that SexpError’s Display would
produce. The happy path allocates nothing for diagnostics, and a large
all-failing vector never builds more than BATCHED_ERROR_CAP messages.