Trait Field

Source
pub unsafe trait Field<Base> {
    type Type: ?Sized;

    const NAME: &'static str;

    // Required method
    unsafe fn map(ptr: *const Base) -> *const Self::Type;
}
Expand description

Information of a field of struct Base.

§Safety

The field must represent a field named NAME in a type Base that has the type Type. The map function must be implemented such that it returns a pointer to the field.

This trait should not be implemented manually; instead, use the #[derive(Field)] instead.

Required Associated Constants§

Source

const NAME: &'static str

The name of the field.

Required Associated Types§

Source

type Type: ?Sized

The type of the field.

Required Methods§

Source

unsafe fn map(ptr: *const Base) -> *const Self::Type

Adjust the pointer from the containing struct to the field.

§Safety

ptr must be a non-null and aligned pointer to Self::Base.

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§