Conversion between `Box<T: Unalign>` and `Box<[u8]>`
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 179
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 29
Description
There's no safe way to no-op convert between allocated bytes and allocated `T` when `T` is unaligned and `FromBytes + IntoBytes`. An `Immutable` bound is not needed in any case because `Box` is non-aliasing like `&mut`.
Future design thinking:
- What about `Rc` and `Arc`? `Cow` should be as trivial as `Box` if not as direct. `Cow` and `Rc` both require `Immutable` as they are shared pointers.
- Why is there not `impl ByteSlice for Box` so it can be used in `Ref` with looser requirements (`T: Unalign` is no longer needed)?
- There should be conversions that copy into a `Box` and ones that convert a box into another. What should they be named? `read_box_from_bytes(&[u8]) -> Box` and `new_box_from_bytes(Box<[u8]>) -> Box`? The latter requires `Unalign` but the former does not as it allocates.
Contributor guide
Assessment
This issue has not been assessed yet.