Rust takes a unique approach to function types, for both closures and fn items. In this video we'll talk about a way to fit these strange function types into your existing understanding of what types are. Then we'll look at how another language (okay, it's C++) does function types in a way that causes poor codegen in generic higher-order functions if you aren't careful--and how/why Rust avoids this problem.
Compiler Explorer - godbolt.org/
Godbolt code samples from the video:
C++ - godbolt.org/z/xo83Ecfqb
Rust - rust.godbolt.org/z/E5fvaxWPM
Rust Stuff
fn pointers vs. fn items - doc.rust-lang.org/std/primiti...
Fn (the trait) - doc.rust-lang.org/std/ops/tra...
C++ Stuff
Decay - en.cppreference.com/w/cpp/typ...
Boost.TypeIndex - www.boost.org/doc/libs/1_82_0...
std::reduce - en.cppreference.com/w/cpp/alg...
Ranges - en.cppreference.com/w/cpp/ranges
static - en.cppreference.com/w/cpp/lan...
I use the amazing Manim library for animating these videos, and I edit them with Blender and Audacity.
www.manim.community/
www.blender.org/
www.audacityteam.org/
16 июн 2024