subst -> instantiate
This commit is contained in:
parent
af68593179
commit
3c52a3e280
25 changed files with 66 additions and 75 deletions
|
@ -162,14 +162,13 @@ fn foo<T>(x: T) {
|
|||
```
|
||||
|
||||
The machine code for `foo::<u8>()`, `foo::<bool>()`, `foo::<String>()`, or any
|
||||
other type substitution is different. Hence the compiler generates the
|
||||
other instantiation is different. Hence the compiler generates the
|
||||
implementation on-demand. If you call `foo()` with a `bool` parameter, the
|
||||
compiler will only generate code for `foo::<bool>()`. When we have additional
|
||||
type parameters, the number of monomorphized implementations the compiler
|
||||
generates does not grow drastically, since the compiler will only generate an
|
||||
implementation if the function is called with unparameterized substitutions
|
||||
(i.e., substitutions where none of the substituted types are themselves
|
||||
parameterized).
|
||||
implementation if the function is called with fully concrete arguments
|
||||
(i.e., arguments which do not contain any generic parameters).
|
||||
|
||||
However, with trait objects we have to make a table containing _every_ object
|
||||
that implements the trait. Now, if it has type parameters, we need to add
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue