Runtime-safe reduce over an array whose element type A may be narrower than
the accumulator type B. Centralizes the single as unknown as B cast that's
otherwise spread across every container's implementation.
Safety: the cast is sound because the Widen<A, B> type-level constraint at the
public API layer guarantees A <: B. When that holds, A values flowing into the
callback are valid B values at runtime — exactly what Scala's [B >: A] provides.
Runtime-safe
reduceover an array whose element typeAmay be narrower than the accumulator typeB. Centralizes the singleas unknown as Bcast that's otherwise spread across every container's implementation.Safety: the cast is sound because the
Widen<A, B>type-level constraint at the public API layer guaranteesA <: B. When that holds, A values flowing into the callback are valid B values at runtime — exactly what Scala's[B >: A]provides.