-
Notifications
You must be signed in to change notification settings - Fork 46
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
Remove uses of unsafe
.
#142
Conversation
b83370b
to
a2c1ea1
Compare
a2c1ea1
to
9ce20ce
Compare
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've highlighted important changes with individual comments. These include:
- design decisions
- possible performance footguns
- changes potentially affecting stability
src/uint.rs
Outdated
where | ||
Bn: Copy |
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 Bn: Copy
bound is needed so we can produce an instance of the least significant bit from a reference to a UInt
.
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 have no objection to this, but couldn't we alternatively make get_bit
take things by 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.
We could! We'd just need to add an extra Copy
bound to the PartialDiv*
implementations.
Per #63 (comment), this may not actually pose any performance issue. |
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 is great, thank you for doing this!
Would you mind just running cargo fmt
? That should be enough to get the build passing.
src/uint.rs
Outdated
where | ||
Bn: Copy |
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 have no objection to this, but couldn't we alternatively make get_bit
take things by value?
Thanks again for doing this, I am very excited to get it merged. :) |
Fixes #126 by completely removing all instances of
unsafe
. Instead,Unsigned
values are flowed through the methodscore::ops
andtype_operator
traits. The appropriate methods have been added to thePrivate*
traits, as needed.This pull request takes an aggressive approach, but it may not be desirable to remove all instances of
unsafe
. This pull request:TArr
I'll spotlight where these changes occur with pull-request comments.