Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions core/result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@

// Result is a golang compatible generic result type
type Result[O any, X any] interface {
isResult(ok O, err X)
Ok() *O
Err() *X
}

type okResult[O any, X any] struct {
value O
}

func (o *okResult[O, X]) Ok() *O { return &o.value }
func (o *okResult[O, X]) Err() *X { return nil }

Check warning on line 20 in core/result/result.go

View check run for this annotation

Codecov / codecov/patch

core/result/result.go#L19-L20

Added lines #L19 - L20 were not covered by tests

type errResult[O any, X any] struct {
value X
}

func (o *okResult[O, X]) isResult(ok O, err X) {}
func (e *errResult[O, X]) isResult(ok O, err X) {}
func (e *errResult[O, X]) Ok() *O { return nil }
func (e *errResult[O, X]) Err() *X { return &e.value }

Check warning on line 27 in core/result/result.go

View check run for this annotation

Codecov / codecov/patch

core/result/result.go#L26-L27

Added lines #L26 - L27 were not covered by tests

// MatchResultR3 handles a result with functions returning 3 values
func MatchResultR3[O any, X any, R0, R1, R2 any](
Expand Down