-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Clean up some trait impls in core::num. #15900
Conversation
|
||
#[inline] | ||
fn is_zero(&self) -> bool { *self == $v || *self == -$v } | ||
fn is_zero(&self) -> bool { *self == Zero::zero() } |
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.
If you're going to use Zero::zero()
here you may as well make this a default method implementation on the trait.
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.
Tried that, but it doesn't work as Zero
doesn't need Eq
or PartialEq
.
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.
Ah, fair enough. Well, in that case, is there any particular reason to use Zero::zero()
here instead of just using $v
as was previously done? After optimization it should ultimately generate the same code, but it just seems simpler (to me as a reader of the code) to continue using $v
.
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.
Dunno, if this wasn't in a macro I'd say: Keep the magic constant in one place, so you can change it easily – it's not so bad in a macro I guess. Want me to change it back?
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.
I agree, if it wasn't a macro I'd use Zero::zero()
. But it is a macro, which means the magic constant stays in one location in the source code.
I'd be happier if you changed it back.
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
@kballard Fixed it. |
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
internal: Disable win32-ia32 VSIX builds https://code.visualstudio.com/updates/v1_84#_windows-32bit-support-ends
This removes the special casing for
float
s where it was not necessary, as-0.0 == 0.0
.