Skip to content

Commit

Permalink
fix: add bool output to Result.Get()
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Jan 24, 2024
1 parent a0bb6d1 commit 63d6e80
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion result.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Result[T any, E error] interface {
IsOkAnd(fn func(v T) bool) bool
IsErr() bool
IsErrAnd(fn func(v E) bool) bool
Get() (T, E)
Get() (T, E, bool)
Expect(panicV any) T
ExpectErr(panicV any) E
Unwrap() T
Expand Down
4 changes: 2 additions & 2 deletions result_err.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func (e Err[T, E]) IsErrAnd(fn func(e E) bool) bool {
return fn(e.err)
}

func (e Err[T, E]) Get() (T, E) {
func (e Err[T, E]) Get() (T, E, bool) {
var def T
return def, e.err
return def, e.err, false
}

func (e Err[T, E]) Expect(panicV any) T {
Expand Down
4 changes: 2 additions & 2 deletions result_ok.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func (o Ok[T, E]) IsErrAnd(fn func(e E) bool) bool {
return false
}

func (o Ok[T, E]) Get() (T, E) {
func (o Ok[T, E]) Get() (T, E, bool) {
var def E
return o.v, def
return o.v, def, true
}

func (o Ok[T, E]) Expect(panicV any) T {
Expand Down

0 comments on commit 63d6e80

Please sign in to comment.