pub trait CTOffset<Target> {
type Offset: Unsigned + Add<U1>;
// Required method
fn offset() -> usize;
}Expand description
Trait used to calculate the 0-indexed offset of a specific type item within compile time structures.
Cast the structure as CTOffset. If this trait is implemented, you can query the
offset of the requested item from CTOffset::Offset.
Alternatively a value can be constructed representing the offset, just call
CTOffset::offset.
** Preferably use the CTOffsetExt trait! **
§Note
If the requested type cannot be found within the implemented structure,
CTConsOffsetInvalid is returned.
§Example
let offset = <Cons<Cons<Cons<CTConsTerm, u8>, u32>, u64> as CTOffset<u64>>::offset();
assert_eq!(offset, 2); // Note: Offset is 0-indexed!Required Associated Types§
Required Methods§
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.