filmov
tv
Generic Functions | Rust Language
Показать описание
Generic functions helps prevent code duplication, you can use a generic type T with a zero cost abstraction. What does this actually look like? The video shows how you use T instead of say u8, or f32, or f64. Note: Using PartialOrd tells the compiler that the types are types which must be comparable. Without this, the code won't compile.
I originally learned this from a very good tutorial by Barron Stone if anyone is interested.
Try the code here in Rust Playground :
Gist here :
It would be amazing if you want to support my channel via Patreon, so I don't have to borrow &money! 🥴
#LearnRust #rustlang #rustprogramming
I originally learned this from a very good tutorial by Barron Stone if anyone is interested.
Try the code here in Rust Playground :
Gist here :
It would be amazing if you want to support my channel via Patreon, so I don't have to borrow &money! 🥴
#LearnRust #rustlang #rustprogramming