structural-assert

Crates.iostructural-assert
lib.rsstructural-assert
version0.1.0
sourcesrc
created_at2021-04-21 07:34:28.344926
updated_at2021-04-21 07:34:28.344926
descriptionProc macro to generate tests which make assertions about a struct's layout.
homepage
repositoryhttps://github.com/gcoakes/structural-assert
max_upload_size
id387489
size10,183
Gregory Oakes (gcoakes)

documentation

README

structural-assert

Inline assertions of the structural layout of a struct. This was implemented exclusively to make it easier to implement structs which conform to a specification which defines the start and end of a field. The specific use case was initially to help faithfully reproduce structures from the NVMe spec.

Usage

ust structural_assert::test_structure;

#[test_structure(size = 20)]
#[repr(C, packed)]
pub struct Foo {
    #[loc(0:0)]
    pub a: u8,
    #[loc(1:1)]
    pub b: u8,
    #[loc(2:3)]
    pub c: u16,
    #[loc(4:19)]
    pub d: u128,
}
Commit count: 1

cargo fmt