Documentation
¶
Overview ¶
Package result provides utilities for dealing with iterators that can fail during iteration.
Result is useful to make it harder for callers to ignore errors. Using iter.Seq2[V, error] can make it easy to accidentally ignore errors:
func myIter() iter.Seq2[V, error] { ... } func main() { for v := range myIter() { /* errors are ignored! */ } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Result ¶
type Result[V any] struct { // contains filtered or unexported fields }
Result is a type used for representing a result from an operation that can fail.
type Seq ¶
Seq is an iterator over sequences of result values. When called as seq(yield), seq calls yield(r) for each value r in the sequence, stopping early if yield returns false.
See the iter package for more information on iterators.
func Iter ¶
Iter produces a new Seq[V] from a given function that can fail. Values passed to yield are wrapped in a call to Value, while a non-nil error is wrapped in a call to Error.
Iter makes it easier to write failable iterators and removes the need to manually wrap values and errors into a Result.