Support container conversions (and maybe other container types?)
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 179
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 29
Description
*For two possible approaches, see #1183 and #1735.*
Currently, we support `T -> U` conversions using the [transmute! macro](https://docs.rs/zerocopy/0.6.1/zerocopy/macro.transmute.html) 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](https://doc.rust-lang.org/nightly/std/boxed/index.html#memory-layout) guarantee `Box`'s layout for `Sized` types)
- `ManuallyDrop` (the [docs](https://doc.rust-lang.org/nightly/core/mem/struct.ManuallyDrop.html) guarantee that `ManuallyDrop`'s layout is equivalent to `T`'s)
- `Wrapping` (the [docs](https://doc.rust-lang.org/nightly/core/num/struct.Wrapping.html#layout-1) guarantee that `Wrapping`'s layout is equivalent to `T`'s)
...and possibly others.
This will help unblock [ICU4X using zerocopy](https://github.com/unicode-org/icu4x/issues/2798).
Contributor guide
Assessment
This issue has not been assessed yet.