Skip to content

Introduce custom derive for ByteValued/replace ByteValued with zerocopy #246

@Manishearth

Description

@Manishearth

ByteValued is an unsafe trait and implementing it is tricky with the padding requirement. But I think it can be autoderived.

Basically, a custom derive that does two things:

  • Emits something like const __ASSERT_SIZES_Foo: [(); mem::size_of::<Foo>()] = [(); mem::size_of::<Field1>() + mem::size_of::<Field2>() + ...] ] ] to assert that there is no padding
  • Emit some test function that ends up asserting bounds on all subfields.

This might significantly reduce the amount of unsafe needed by crate users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions