pub trait GetPubFieldOffset<FN>: GetFieldOffset<FN, Privacy = IsPublic> {
const OFFSET: FieldOffset<Self, Self::Type, Self::Alignment> = _;
}Expand description
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)));
}
Provided Associated Constants§
Sourceconst OFFSET: FieldOffset<Self, Self::Type, Self::Alignment> = _
const OFFSET: FieldOffset<Self, Self::Type, Self::Alignment> = _
The offset of the field.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".