-
Notifications
You must be signed in to change notification settings - Fork 9
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 zerovec ULE impls for TinyStr #44
Conversation
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 in general, for TinyStr, we should just try to never expose it publicly as an integer; we should instead operate on sized byte arrays, like [u8; 4]
.
|
||
// This converts between endiannesses twice: TinyStr::new_unchecked() | ||
// takes in a native endian integer, which we produce via from_unaligned() | ||
Self::new_unchecked(<$integer>::from_unaligned(&unaligned.0)) |
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.
Suggestion: Create a const unsafe
constructor for TinyStr (in the normal library code) that takes a &[u8; $size]
; it can use <$integer>::from_ne_bytes()
in its impl. Then here, pass in the 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.
I'd rather do this when we figure out the overall endianness story.
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.
Progress on unicode-org/icu4x#652 , fixes #41