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

Implement TryFromBytes for Unalign? #320

Closed
joshlf opened this issue Sep 4, 2023 · 1 comment
Closed

Implement TryFromBytes for Unalign? #320

joshlf opened this issue Sep 4, 2023 · 1 comment

Comments

@joshlf
Copy link
Member

joshlf commented Sep 4, 2023

Should we impl TryFromBytes for Unalign<T> where T: TryFromBytes? There are a few cases, and many of them are thorny:

  • For T: Unaligned, we could already support this by delegating to T::is_bit_valid.
  • For T: !Unaligned (ie, T in the general case without an Unaligned bound), we can't delegate to T::is_bit_valid because it requires an aligned MaybeValid<T>. We could copy the Unalign<T> into the local stack frame in order to ensure its alignment and then call T::is_bit_valid on the local copy, but that could be very expensive.
  • If we add support for unsized T, then for T: !Unaligned, copying into the local stack frame isn't even an option.

cc @kupiakos

@joshlf
Copy link
Member Author

joshlf commented May 19, 2024

Done in #817.

@joshlf joshlf closed this as completed May 19, 2024
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

No branches or pull requests

1 participant