-
Notifications
You must be signed in to change notification settings - Fork 206
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
Convert Direction from enum into a discriminated union #1618
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1618 +/- ##
==========================================
- Coverage 64.92% 64.88% -0.04%
==========================================
Files 202 203 +1
Lines 12608 12603 -5
==========================================
- Hits 8186 8178 -8
- Misses 3709 3711 +2
- Partials 713 714 +1
Continue to review full report at Codecov.
|
78128e7
to
0865bf6
Compare
8959fb7
to
157c4eb
Compare
0865bf6
to
dc9c56f
Compare
sourceType := fn.direction.SelectType(fn.otherDefinition.Type(), receiver.Type()) | ||
destinationType := fn.direction.SelectType(receiver.Type(), fn.otherDefinition.Type()) |
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 bit is fiddly but I think still better than the original.
What this PR does / why we need it:
Code that needed to make a decision based on the direction of conversion always needed to handle "other" values with a panic; converting the type into an interface allows us to ensure that only valid implementations are provided, simplifying consumption.
This type will be used more frequently in upcoming PRs to implement type conversion.
Harvested from PR #1533
Prerequisites
master
Special notes for your reviewer:
Let us take a moment and lament how
SelectString()
andSelectType
would be a single method if Go had generics right now.How does this PR make you feel: