08 Traits and Generics | Rust Tutorials

preview_player
Показать описание
Traits in Rust are very similar to type classes in Haskell or interfaces in Java.
It's a way of abstracting the underlying data type and only interacting with it using methods and associate functions. But there are some cool features of traits that aren't seen in many other languages. For example, you can implement traits for data types that are not your own (i.e. String).

Find me elsewhere:

And coupling traits with Generics gives even more power to the developer.

Generics a way to code without specifying an underlying concrete data type. Instead, developers use placeholders and define their behaviors using traits. During compilation, the compiler switches out the placeholders for real data types. This bypasses the runtime costs needed to facilitate polymorphism, a different mechanism that tries to address the same issues as generics.

Hope you guys learn something new!
If you have topics you want me to cover in future videos, leave a comment down below.
Рекомендации по теме
Комментарии
Автор

One of the best video on traits on youtube. Thank you!

axosi
Автор

Thanks Jeff. As an experienced developer, this was just the right pace for me to learn Rust. I got lost at the end of the Traits and Generics video, but other than that it was great.

tomevans
Автор

GREAT tutorial! How would I proceed to know more about rust after this?

romanmunar
join shbcf.ru