pub trait Instantiate {
// Required method
fn instantiate(self, args: &[TypeReference]) -> Self;
}
Required Methods§
Sourcefn instantiate(self, args: &[TypeReference]) -> Self
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.
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.