-
Notifications
You must be signed in to change notification settings - Fork 132
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 the cast
dependency.
#124
Conversation
It was only used between usize and u64 in parts of the code that were marked with `#[cfg(target_pointer_width = "64")]`, which guarantees usize is 64 bits.
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.
Great, thank you! I left one small comment, otherwise this looks good to me.
src/addr.rs
Outdated
/// Creates a virtual address from the given pointer | ||
pub fn from_ptr<T>(ptr: *const T) -> Self { | ||
Self::new(cast::u64(ptr as usize)) | ||
Self::new(ptr as u64) | ||
} |
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 function does not have a #[cfg(target_pointer_width = "64")]
. There are no >64-architectures right now, so this cast should never be truncating in practice, but maybe we should add the cfg attribute anyway?
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.
Looks like cfg
was already missing there. Adding it would technically be a breaking change.
It could also get a #[cfg(any(target_pointer_width = "32", target_pointer_width = "64")]
to make it 'less breaking'. Not sure if anybody would want to use this function on 32-bit though.
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.
Adding #[cfg(any(target_pointer_width = "32", target_pointer_width = "64")]
with a short comment that target_pointer_width = "32"
is only added for reducing breakage seems like the best option to me.
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.
Sure. Done.
Perfect, thanks! |
Released as version 0.9.2. |
It was only used between usize and u64 in parts of the code that were
marked with
#[cfg(target_pointer_width = "64")]
, which guaranteesusize is 64 bits.
See #90.