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

Use/require byte equality in VarZeroVec #1103

Merged
merged 7 commits into from
Sep 27, 2021

Conversation

Manishearth
Copy link
Member

Part of #1082

Fixes #1083

@Manishearth Manishearth requested a review from sffc as a code owner September 25, 2021 02:18
@Manishearth Manishearth mentioned this pull request Sep 25, 2021
29 tasks
utils/zerovec/src/ule/mod.rs Outdated Show resolved Hide resolved
utils/zerovec/src/ule/mod.rs Show resolved Hide resolved
utils/zerovec/src/ule/mod.rs Outdated Show resolved Hide resolved
utils/zerovec/src/ule/mod.rs Outdated Show resolved Hide resolved
@Manishearth Manishearth requested a review from sffc September 25, 2021 07:27
Copy link
Member

@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.

Please add the default implementation of the two trait functions where that is possible, and remove the overrides from the impls where possible.

@Manishearth Manishearth requested a review from sffc September 25, 2021 17:22
@@ -66,11 +83,19 @@ where
///
Copy link
Member

Choose a reason for hiding this comment

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

Please add a default impl for from_byte_slice_unchecked as well. For ULE, you can use mem::size_of to figure out how long to make the resulting slice. For VarULE, I think you can just cast it, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't cast it for VarULE because there's no way to generically do the inverse operation of size_of_val() ("I have X bytes, tell me what the pointer metadata should be"). For example, consider what would happen with stuff like struct ComplexULE(u8, char::ULE, [u32::ULE]), calculating the pointer metadata for that is very specific to that type.

Now fortunately the only kind of DST we can theoretically support are slice DSTs and compound slice DSTs, but just to give an example of why the inverse of size_of_val() is untractable: how woudl you solve that for trait objects? At least for compound slice-based DSTs rustc could theoretically add APIs to std::ptr::metadata that let you do this.

@Manishearth Manishearth requested a review from sffc September 26, 2021 01:14
@Manishearth Manishearth merged commit 31497db into unicode-org:main Sep 27, 2021
@Manishearth Manishearth deleted the ule-eq branch September 27, 2021 21:22
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.

Allow equality to be byte equality on VarZeroVec
2 participants