google / google/zerocopy

Support transmuting `Ref<B, T>` into `Ref<B, U>`

Open
#2,133 0 comments 0 reactions 0 assignees View on GitHub
customer-request
Dominant language
Rust
Stars
2.6k
Forks
179
Avg merge
1d 19h
Merged PRs (30d)
29

Description

Given `T: IntoBytes` and `U: FromBytes`, we use the same logic as `transmute_ref!`, only with `Ref` instead of references. This will need to be fallible for size and alignment reasons.

This would permit Fuchsia's Netstack3 to implement [this code](https://fuchsia-review.googlesource.com/c/fuchsia/+/1168175/2) generically, e.g. replacing `pub fn as_v1_query(&self) -> Mldv1Body<&[u8]>` with `pub fn into_v1_query(self) -> Mldv1Body`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.