Skip to content

Commit 26f0299

Browse files
committed
Trait bounds are discussed later
Beside trait bounds are discussed in 10.2 not in 10.1, _monomorphization_ relates to generics in general not only those bound by/to trait.
1 parent c79ce6b commit 26f0299

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ch17-02-trait-objects.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ didn’t mean to pass and so should pass a different type or we should implement
232232
Recall in the [“Performance of Code Using
233233
Generics”][performance-of-code-using-generics]<!-- ignore --> section in
234234
Chapter 10 our discussion on the monomorphization process performed by the
235-
compiler when we use trait bounds on generics: the compiler generates
236-
nongeneric implementations of functions and methods for each concrete type that
237-
we use in place of a generic type parameter. The code that results from
238-
monomorphization is doing *static dispatch*, which is when the compiler knows
239-
what method you’re calling at compile time. This is opposed to *dynamic
240-
dispatch*, which is when the compiler can’t tell at compile time which method
241-
you’re calling. In dynamic dispatch cases, the compiler emits code that at
242-
runtime will figure out which method to call.
235+
compiler on generics: the compiler generates nongeneric implementations
236+
of functions and methods for each concrete type that we use in place of
237+
a generic type parameter. The code that results from monomorphization is
238+
doing *static dispatch*, which is when the compiler knows what method you’re
239+
calling at compile time. This is opposed to *dynamic dispatch*, which is
240+
when the compiler can’t tell at compile time which method you’re calling.
241+
In dynamic dispatch cases, the compiler emits code that at runtime will
242+
figure out which method to call.
243243

244244
When we use trait objects, Rust must use dynamic dispatch. The compiler doesn’t
245245
know all the types that might be used with the code that’s using trait objects,

0 commit comments

Comments
 (0)