rafx_base/
offsetof.rs

1#[macro_export]
2macro_rules! offset_of {
3    ($base:path, $field:ident) => {{
4        #[allow(unused_unsafe)]
5        unsafe {
6            let b: $base = std::mem::zeroed();
7            (&b.$field as *const _ as isize) - (&b as *const _ as isize)
8        }
9    }};
10}