Type

Trait Type 

Source
pub trait Type {
    type Meta: 'static;

    const METATYPE: MetaType;

    // Required methods
    fn meta(self: *const Self) -> Self::Meta;
    fn data(self: *const Self) -> *const ();
    fn data_mut(self: *mut Self) -> *mut ();
    fn dangling(t: Self::Meta) -> NonNull<Self>;
    fn fatten(thin: *mut (), t: Self::Meta) -> *mut Self;

    // Provided method
    fn meta_type(self: *const Self) -> MetaType { ... }
}
Expand description

Implemented on all types, it provides helper methods to determine whether a type is TraitObject, Slice or Concrete, and work with them respectively.

Required Associated Constants§

Source

const METATYPE: MetaType

Enum describing whether a type is TraitObject, Slice or Concrete.

Required Associated Types§

Source

type Meta: 'static

Type of metadata for type.

Required Methods§

Source

fn meta(self: *const Self) -> Self::Meta

Retrieve TraitObject, Slice or Concrete meta data respectively for a type

Source

fn data(self: *const Self) -> *const ()

Retrieve pointer to the data

Source

fn data_mut(self: *mut Self) -> *mut ()

Retrieve mut pointer to the data

Source

fn dangling(t: Self::Meta) -> NonNull<Self>

Create a dangling non-null *const Self with the provided Self::Meta.

Source

fn fatten(thin: *mut (), t: Self::Meta) -> *mut Self

Create a *mut Self with the provided Self::Meta.

Provided Methods§

Source

fn meta_type(self: *const Self) -> MetaType

Helper method describing whether a type is TraitObject, Slice or Concrete.

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<T: ?Sized> Type for T