Skip to content
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

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

sno2
Copy link
Contributor

@sno2 sno2 commented Oct 30, 2023

This refactors the old code that used to convert to a value before matching on itself to use the enum variants.

Copy link
Collaborator

@aapoalas aapoalas left a 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

@aapoalas aapoalas merged commit 82c7aa6 into main Oct 30, 2023
1 check passed
@aapoalas aapoalas deleted the refactor/number branch October 30, 2023 19:53
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,
Copy link

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

Copy link
Contributor Author

@sno2 sno2 Oct 30, 2023

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?

Copy link
Collaborator

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?

Copy link
Contributor Author

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...

Copy link

@ghost ghost Oct 30, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants