Skip to content

v1.0.227

Latest

Choose a tag to compare

@enetx enetx released this 04 Jul 14:58
feat!: SeqResult lazy transformers are consumer-driven on Err

Map, Filter, Exclude, Dedup, Unique, Skip, StepBy, Take, Chain, Intersperse,
Inspect, Scan, and FlatMap no longer terminate the sequence at the first Err:
the Err is yielded downstream like any other element and the source keeps
iterating for as long as the consumer keeps accepting values. Previously the
transformer itself returned false after yielding an Err, so a single transient
error silently truncated the rest of the stream even when the consumer wanted
to skip it.

Fail-fast is now exclusively the consumer's choice, matching the Rust idiom
(itertools map_ok/filter_ok + try_* terminals):
- break on the Err element (yield returns false), or
- use the short-circuiting terminals — TryCollect, Fold, Reduce, All, Any,
  First, Find, Nth — whose behavior is unchanged.

Err elements stay transparent to transformer logic: Take/Skip count only Ok
elements, Dedup/Unique exclude Err from comparison state, Intersperse emits no
separator around an Err.

Tests: new result_iter_errcont_test.go covers continuation for all 13
transformers plus guards locking consumer-break and TryCollect fail-fast; the
two tests that encoded the old terminate-on-Err contract (FlatMap cross-type,
ErrSeq Chain) now assert both sides — continuation under a continuing consumer
and fail-fast under a breaking one.