Using polymorphic async closures in rust

preview_player
Показать описание
This video covers how to use closures returning futures in rust.

It touches on advanced topics such as pinning, Unpin/!Unpin, higher rank trait bounds and dynamic dispatch. It is not a beginner video.

Here is some further reading material mentioned in the video:

Рекомендации по теме
Комментарии
Автор

Things are getting much more complicated when you deal with async in Rust. Thanks for your research and explanation.

zveroboy
Автор

Nice video thank you !

I think it is better in the anonymous lifetime trick to use the new "use" keyword. This is because the trait bound constraints your Future to live at least for '_ but I think you actually want to say that it must live at most for '_. You can have many issues satisfying the borrow checker to accept your callback by not using the correct lifetime constraint like this in the API.

So I think your type should be Box<dyn for<'a> Fn(&'a str, &'a str) -> Pin<Box<dyn Future<Output=()> + use<'a>>>>

If you use an older Rust version you would use the "Capture Trick" instead.

theopantamis
Автор

Each time I think I finally understand rust, I get dropped a new concept that makes me smack my head and realize I barely scratch the surface 😅

scott_boyce
Автор

Demn, this is so underrated, you deserve more subs 💪

taquanminhlong
Автор

I think my mind just exploded. Awesome vid

XeliyataOwO
join shbcf.ru