reflectapi_schema

Trait Instantiate

source
pub trait Instantiate {
    // Required method
    fn instantiate(self, args: &[TypeReference]) -> Self;
}

Required Methods§

source

fn instantiate(self, args: &[TypeReference]) -> Self

Apply type arguments to a generic struct or enum. This should return a non-generic instance with all type parameters substituted with the matching type arguments.

Example: Given a generic struct struct Foo<T, U> { a: T, b: U } and type arguments [i32, String], the instantiate(struct Foo<T, U>, [i32, String]) should be a non-generic struct struct Foo { a: i32, b: String }. This is implemented by generating a substitution map from the type parameters to the type argument T -> i32, U -> String and then substituting each occurence of the type parameter with the type argument.

Object Safety§

This trait is not object safe.

Implementors§