macro_rules! offset_of {
($($tt:tt)*) => { ... };
}
Expand description
Returns the offset of a field.
#[repr(C)]
struct Data {
byte: u8,
float: f32,
}
let offset = dataview::offset_of!(Data.float);
assert_eq!(offset, 4);
const OFFSET: usize = dataview::offset_of!(Data.float);
assert_eq!(OFFSET, 4);
The syntax is $ty.$field
.
No support for tuples, tuple structs or unions.
No support for projecting through multiple fields.