reference: vtable entries are resolved at runtime#31677
reference: vtable entries are resolved at runtime#31677bors merged 2 commits intorust-lang:masterfrom ivan:doc-vtable
Conversation
|
I think the reference was right, but perhaps a bit unclear: The vtable itself is built at compile time, so the vtable entry for all methods is known at compile time, but it's not known which method the entry actually points to. |
|
/cc @nikomatsakis @aturon what is the best wording here? |
|
I agree with @jonas-schievink. It'd be mildly more clear as
instead of:
but, honestly, the whole paragraph could probably use a rewrite for clarity. |
src/doc/reference.md
Outdated
|
|
||
| The purpose of trait objects is to permit "late binding" of methods. A call to | ||
| a method on a trait object is only resolved to a vtable entry at compile time. | ||
| a method on a trait object is only resolved to a vtable entry at runtime. |
There was a problem hiding this comment.
I think I would probably say something like "Calling a method on a trait object results in virtual dispatch at runtime: that is, a function pointer is loaded from the trait object vtable and invoked indirectly."
|
@bors: r+ rollup |
|
📌 Commit 58f0d72 has been approved by |
I sure hope this fix is right cc @steveklabnik
I sure hope this fix is right
cc @steveklabnik