FromType

Trait FromType 

Source
pub trait FromType<T> {
    // Required method
    fn from_type() -> Self;

    // Provided method
    fn insert_dependencies(_type_registration: &mut TypeRegistration) { ... }
}
Expand description

Trait used to generate TypeData for trait reflection.

This is used by the #[derive(Reflect)] macro to generate an implementation of TypeData to pass to TypeRegistration::insert.

Required Methods§

Source

fn from_type() -> Self

Creates an instance of Self for type T.

Provided Methods§

Source

fn insert_dependencies(_type_registration: &mut TypeRegistration)

Inserts TypeData dependencies of this TypeData. This is especially useful for trait TypeData that has a supertrait (ex: A: B). When the TypeData for A is inserted, the B TypeData will also be inserted.

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§