macro_rules! out_field {
($out:ident.$field:tt) => { ... };
}
Expand description
Returns a tuple of the field offset and a mutable pointer to the field of the given struct pointer.
Examples
use core::mem::MaybeUninit;
use rkyv::out_field;
struct Example {
a: i32,
b: bool,
}
let mut result = MaybeUninit::<Example>::zeroed();
let out = result.as_mut_ptr();
let (a_off, a) = out_field!(out.a);
unsafe { a.write(42); }
let (b_off, b) = out_field!(out.b);
unsafe { b.write(true); }
let result = unsafe { result.assume_init() };
assert_eq!(result.a, 42);
assert_eq!(result.b, true);