google / google/zerocopy

Idea: `AsBytes` convenience macro and trait for `IntoBytes + Immutable`

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

Description

It would be ergonomic to have an `AsBytes` derive macro to derive both `IntoBytes` and `Immutable`, as well as a convenience blanket-implemented trait `AsBytes` for all `T: ?Sized + Immutable + IntoBytes`. This would [not be](https://docs.rs/zerocopy/latest/zerocopy/byte_slice/trait.ByteSliceMut.html#impl-ByteSliceMut-for-B) the first blanket-implemented trait in zerocopy 0.8.

This'd shorten the common `#[derive(FromBytes, IntoBytes, Immutable)]` and `T: Immutable + IntoBytes` into `#[derive(AsBytes, FromBytes)]` and `T: AsBytes`.

It'd also help migrations from 0.7 to some degree, even if the details of the names are changing.

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.