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

Support container conversions (and maybe other container types?) #114

Open
joshlf opened this issue Nov 2, 2022 · 3 comments
Open

Support container conversions (and maybe other container types?) #114

joshlf opened this issue Nov 2, 2022 · 3 comments
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking

Comments

@joshlf
Copy link
Member

joshlf commented Nov 2, 2022

For two possible approaches, see #1183 and #1735.

Currently, we support T -> U conversions using the transmute! macro when T: AsBytes, U: FromBytes, and T and U have the same size. In principle, we ought to be able to support a range of conversions for container types wrapping T and U so long as those containers have well-defined layouts. Specifically:

  • Slices
  • Box (the docs guarantee Box's layout for Sized types)
  • ManuallyDrop (the docs guarantee that ManuallyDrop<T>'s layout is equivalent to T's)
  • Wrapping (the docs guarantee that Wrapping<T>'s layout is equivalent to T's)

...and possibly others.

This will help unblock ICU4X using zerocopy.

@ileixe
Copy link

ileixe commented Jan 31, 2023

To achieve #149, I'd like to try to implement Box for this issue if possible. Could you please give me a guide for it?

@joshlf
Copy link
Member Author

joshlf commented Aug 1, 2023

Hey @ileixe , apologies for the radio silence! I likely won't have time to get to this anytime soon unfortunately.

@ileixe
Copy link

ileixe commented Aug 2, 2023

Hey joshlf, nevermind, we have a life. :) I got an another approach so you don't have to be sorry. Thanks for answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking
Projects
None yet
Development

No branches or pull requests

2 participants