|
|
|
|
|
by alilleybrinker
602 days ago
|
|
In part two, the author explains trait objects in a way that is, I think, a little misleading. They're right that trait objects are dynamically sized types, which means they can't be passed by value to functions, but wrong that they need to be boxed; they can instead be put behind a reference. Both of the following are valid types. type DynFutureBox = Pin<Box<dyn Future<Output = ()>>>;
type DynFutureRef<'f> = Pin<&'f dyn Future<Output = ()>>;
You can see this in the Rust Playground here: https://play.rust-lang.org/?version=stable&mode=debug&editio... |
|