Skip to content

Commit

Permalink
Update errable.go
Browse files Browse the repository at this point in the history
Change-Id: Ibc178a9b1a874556a3cb96600801264fb90815ba
  • Loading branch information
andeya committed Oct 13, 2022
1 parent 2de4e3e commit bb07364
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions errable.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,17 @@ func (e Errable[E]) TryPanic() {
panic(e.UnwrapErr())
}
}

func (e Errable[E]) InspectErr(f func(err E)) Errable[E] {
if e.IsErr() {
f(e.UnwrapErr())
}
return e
}

func (e Errable[E]) Inspect(f func()) Errable[E] {
if e.IsOk() {
f()
}
return e
}

0 comments on commit bb07364

Please sign in to comment.