-
Notifications
You must be signed in to change notification settings - Fork 38
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
refactor(number): remove value conversion indirection #45
Conversation
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.
LGTM! Nice cleanup <3
Value::Float(n) => n % 1.0 == 0.0 && n % 2.0 == 0.0, | ||
_ => unreachable!(), | ||
Number::Integer(n) => Into::<i64>::into(n) % 2 == 0, | ||
Number::Float(n) => n % 1.0 == 0.0 && n % 2.0 == 0.0, |
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.
the n % 1.0
was unnecessary here
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.
Nice catch, would you like to PR it?
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.
Actually, isn't the test the wrong way around as well? 3 % 2 == 1
right?
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.
huh, yeah. not sure what I was thinking when I wrote that...
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.
On it. Glad to be back :)
This refactors the old code that used to convert to a value before matching on itself to use the enum variants.