-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add converter between UInt/UInt64/Int/Int64/Float/Double and Bytes. #1341
Add converter between UInt/UInt64/Int/Int64/Float/Double and Bytes. #1341
Conversation
Pull Request Test Coverage Report for Build 4519Details
💛 - Coveralls |
Maybe it would be better to have conversions with BytesView (after we add BytesView of course) graph TD;
Data --> Bytes;
Bytes --> BytesView;
BytesView --> Data;
|
OK. Should I close this PR for now? |
It will come soon, so we can leave this PR as it is now. Or we can merge the |
Can you please rebase to #1394 ? |
Here are three observations from the provided
These issues should be addressed to improve code quality and robustness. |
double/double.mbt
Outdated
pub fn to_be_bytes(self : Double) -> BytesView { | ||
self.reinterpret_as_uint64().to_be_bytes_view() | ||
} | ||
|
||
///| | ||
pub fn to_le_bytes(self : Double) -> BytesView { | ||
self.reinterpret_as_uint64().to_le_bytes_view() | ||
} |
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 think we should use the original implementation that converts data to Bytes
or FixedArray[Byte]
instead of BytesView
.
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.
What do you think @Yu-zh
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 think it's better to return Bytes
.
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.
Reverted those convertors to return Bytes.
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, thank you for your contribution!
No description provided.