Type Alias repr_offset::get_field_offset::PrivFieldType

source ·
pub type PrivFieldType<This, FN> = <This as GetFieldOffset<FN>>::Type;
Expand description

Gets the type of a (potentially) private field in the GetFieldOffset<FN> impl for This.

§Warning

Because the field may be private this can break when asking for the type of fields in types from external crates.

§Example

use repr_offset::{
    get_field_offset::PrivFieldType,
    tstr::TS,
    unsafe_struct_field_offsets,
};

use foo::Foo;

let _: PrivFieldType<Foo, TS!(x)> = 3_u8;
let _: PrivFieldType<Foo, TS!(y)> = 5_u16;
let _: PrivFieldType<Foo, TS!(z)> = 8_u32;
let _: PrivFieldType<Foo, TS!(w)> = 13_u64;

mod foo {
    use super::*;

    #[repr(C)]
    pub struct Foo {
        x: u8,
        pub(super) y: u16,
        pub(crate) z: u32,
        pub w: u64,
    }

    repr_offset::unsafe_struct_field_offsets!{
        alignment = repr_offset::Aligned,
    
        impl[] Foo {
            const OFFSET_X, x: u8;
            pub(super) const OFFSET_Y, y: u16;
            pub(crate) const OFFSET_Z, z: u32;
            pub const OFFSET_W, w: u64;
        }
    }
}