Macro field_offset::offset_of [] [src]

macro_rules! offset_of {
    ($t: path => $f: ident) => { ... };
    ($t: path => $f: ident: $($rest: tt)*) => { ... };
}

This macro allows safe construction of a FieldOffset, by generating a known to be valid lambda to pass to the constructor. It takes a type and the identifier of a field within that type as input.

Examples:

Offset of field Foo().bar

offset_of!(Foo => bar)

Offset of nested field Foo().bar.x

offset_of!(Foo => bar: Bar => x)