Rust's Unique Function Types Explained πŸ€”

Discover how Rust handles closures and fn items with its unique function type system in this insightful video.

Rust's Unique Function Types Explained πŸ€”
Logan Smith
196.9K views β€’ Jul 13, 2023
Rust's Unique Function Types Explained πŸ€”

About this video

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 - https://godbolt.org/

Godbolt code samples from the video:
C++ - https://godbolt.org/z/xo83Ecfqb
Rust - https://rust.godbolt.org/z/E5fvaxWPM

*Rust Stuff*
fn pointers vs. fn items - https://doc.rust-lang.org/std/primitive.fn.html#creating-function-pointers
Fn (the trait) - https://doc.rust-lang.org/std/ops/trait.Fn.html

*C++ Stuff*
Decay - https://en.cppreference.com/w/cpp/types/decay
Boost.TypeIndex - https://www.boost.org/doc/libs/1_82_0/doc/html/boost_typeindex.html
std::reduce - https://en.cppreference.com/w/cpp/algorithm/reduce
Ranges - https://en.cppreference.com/w/cpp/ranges
static - https://en.cppreference.com/w/cpp/language/storage_duration

I use the amazing Manim library for animating these videos, and I edit them with Blender and Audacity.
https://www.manim.community/
https://www.blender.org/
https://www.audacityteam.org/

Video Information

Views

196.9K

Likes

8.8K

Duration

19:52

Published

Jul 13, 2023

User Reviews

4.7
(39)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.