CTOffsetExt

Trait CTOffsetExt 

Source
pub trait CTOffsetExt {
    // Required method
    fn offset_of<X>() -> usize
       where Self: CTOffset<X>;
}
Expand description

Trait used to calculate the offset of a specific type without upcasting to the CTOffset trait.

§Example

type BigList = Cons<Cons<Cons<CTConsTerm, u8>, u32>, u64>;
let offset = BigList::offset_of::<u64>();
assert_eq!(offset, 2);    // Note: Offset is 0-indexed!

Required Methods§

Source

fn offset_of<X>() -> usize
where Self: CTOffset<X>,

Returns the offset of the provided type within the implemented compile time structure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<C> CTOffsetExt for C
where C: CTCons,