google / google/zerocopy

Make `#[derive(IntoBytes)]` support more generic types

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

Description

Here's an idea for making `#[derive(IntoBytes)]` smarter on generic types: we can see from the surface syntax which fields are based on generic types and which are entirely concrete. Then, we can perform `const` computation based on those concrete types to extract *partial* information about the type. We can then use that partial information to infer bounds that must hold of generic types.

For example, if we could use `const` code to compute the maximum alignment that we could tolerate for a given field, then we could emit a bound of `F: Unaligned<{derive_generated_computation}>` for that field.

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.