Skip to content

Commit

Permalink
chore: Optimized codes
Browse files Browse the repository at this point in the history
Change-Id: Idb7a6900e23e6ad91145a75c79ad08b3d46a2002
  • Loading branch information
andeya committed Nov 22, 2022
1 parent 39ca07d commit 33ef780
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions enum_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ func (r EnumResult[T, E]) CtrlFlow() CtrlFlow[E, T] {
//
// If there is an E, that panic should be caught with CatchEnumResult
func (r EnumResult[T, E]) UnwrapOrThrow() T {
if r.IsErr() {
if !r.isErr || r.value == nil {
if r.isErr {
if r.value == nil {
var e E
v := any(e)
panic(panicValue[*any]{&v})
Expand Down
4 changes: 2 additions & 2 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ func (r Result[T]) CtrlFlow() CtrlFlow[error, T] {
//
// If there is an error, that panic should be caught with CatchResult
func (r Result[T]) UnwrapOrThrow() T {
if r.IsErr() {
if !r.inner.isErr || r.inner.value == nil {
if r.inner.isErr {
if r.inner.value == nil {
var err error
v := any(toError(err))
panic(panicValue[*any]{&v})
Expand Down

0 comments on commit 33ef780

Please sign in to comment.