-
Notifications
You must be signed in to change notification settings - Fork 182
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
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.
Please add the default implementation of the two trait functions where that is possible, and remove the overrides from the impls where possible.
@@ -66,11 +83,19 @@ where | |||
/// |
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.
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?
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.
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.
Part of #1082
Fixes #1083