New to rust, and I've been confused on the following:
What are the advantages of manually constructing a
(data, vtable)-like structure, rather than using a dyn trait, which itself should be a (data, vtable) representation?
I've seen this pattern in:
- tokio's RawTask
Neither of these examples have documented the rationale behind this type of design, so I assume I must be missing something obvious.
In this blog post, withoutboats says:
Rust has support for relatively easy dynamic dispatch using trait objects, but because of the rules of object safety, this easy form of dynamic dispatch is often quite limited. Indeed, we’ll find its too limited to support our use case, which is why all of the API proposals have a “Waker” type, instead of just using references to
dyn Waketrait objects.
What are the limitations to dynamic dispatch through normal dyn Traits? Is this the reason why the examples mentioned are above do not use dyn Traits?