-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move catching to either object and make it an either block operator #167
move catching to either object and make it an either block operator #167
Conversation
…x unreachable case warning
core/src/main/scala/ox/either.scala
Outdated
@@ -42,6 +47,23 @@ object either: | |||
) nn: NotNested | |||
): Either[E, A] = boundary(Right(body)) | |||
|
|||
extension [E, A](inline t: Right[E, A]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the comment in code, as to why we need the specialised left/right variants? (avoiding compiler warnings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
core/src/main/scala/ox/either.scala
Outdated
@@ -42,6 +47,23 @@ object either: | |||
) nn: NotNested | |||
): Either[E, A] = boundary(Right(body)) | |||
|
|||
extension [E, A](inline t: Right[E, A]) | |||
/** Unwrap the value of the `Either`, returning value of type `A` on guaranteed `Right` case. */ | |||
transparent inline def ok(): A = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be simplified to t.value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Thanks :) |
also fixes unreachable case warning by adding specialised
ok()
operators: