Open joelposti opened 1 year ago
Heh, you're not the first to ask. The main answer is that it can't be a trait object because the Clone
trait (which Waker
implements) isn't object safe. One could hack around this by always requiring Waker
to be indirected through an Arc
or a Box
(which is possible in std
today), but if that were required by the interface it wouldn't work in embedded/no_std contexts.
I agree it may be useful to add a brief note to this effect!
Thank you for taking your time to explain this. Also, thanks for the link to the Reddit discussion.
On page 134 it is mentioned that a
Waker
has a manually implemented vtable (which functions similarly to the dynamic dispatch). I think a paragraph or an info box elaborating on whyWaker
has a vtable would be a beneficial addition to the book. With my limited knowledge I fail to see why a vtable is needed. Is static dispatch not possible?