Skip to content
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

Merged
merged 3 commits into from
May 12, 2021
Merged

Conversation

Manishearth
Copy link
Collaborator

@Manishearth Manishearth commented May 11, 2021

Progress on unicode-org/icu4x#652 , fixes #41

@Manishearth Manishearth requested a review from sffc May 11, 2021 00:02
Copy link
Collaborator

@sffc sffc left a 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].

Cargo.toml Show resolved Hide resolved
src/ule.rs Outdated Show resolved Hide resolved

// 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))
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#45

@Manishearth Manishearth requested a review from sffc May 11, 2021 21:36
@Manishearth Manishearth merged commit 6d22ca3 into zbraniecki:master May 12, 2021
@Manishearth Manishearth deleted the ule branch May 12, 2021 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate unaligned TinyStr
2 participants