Trait repr_offset::get_field_offset::GetPubFieldOffset[][src]

pub trait GetPubFieldOffset<FN>: GetFieldOffset<FN, Privacy = IsPublic> {
    const OFFSET: FieldOffset<Self, Self::Type, Self::Alignment>;
}

An alias of the GetFieldOffset trait for public fields.

Example

Defining a generic method for all types that have a, and c fields

use repr_offset::{
    for_examples::ReprC,
    get_field_offset::FieldType,
    privacy::{IsPublic, IsPrivate},
    tstr::TS,
    pub_off,
    Aligned, GetPubFieldOffset, ROExtAcc,
};

use std::fmt::Debug;

print_a_c(&ReprC{a: 10, b: 20, c: 30, d: 40 });

fn print_a_c<T>(this: &T)
where
    T: GetPubFieldOffset<TS!(a), Alignment = Aligned>,
    T: GetPubFieldOffset<TS!(b), Alignment = Aligned>,
    FieldType<T, TS!(a)>: Debug,
    FieldType<T, TS!(b)>: Debug,
{
    println!("{:?}", this.f_get(pub_off!(a)));
    println!("{:?}", this.f_get(pub_off!(b)));

}

Associated Constants

const OFFSET: FieldOffset<Self, Self::Type, Self::Alignment>[src]

The offset of the field.

Loading content...

Implementors

impl<FN, Ty> GetPubFieldOffset<FN> for Ty where
    Ty: GetFieldOffset<FN, Privacy = IsPublic>, 
[src]

Loading content...