assert-offset
assert-offset is a simple Rust derive macro for asserting memory offsets within structures.
This can be useful for low level FFI and/or embedded development.
⚠ This crate does not change field offsets, it merely asserts that they are at the expected offsets.
Examples
Usage
use AssertOffsets;
Failing Example
use AssertOffsets;
// Note that we're not using #[repr(C)] here
Compiler Error
error[E0080]: evaluation of constant value failed
--> src\main.rs:3:10
|
3 | #[derive(AssertOffsets)]
| ^^^^^^^^^^^^^ the evaluated program panicked at 'Field `Foo::b` is not at expected offset 0x2'
License
This project is licensed under the MIT License.