Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

How Not to Rely on Inheritance in Rust - Traits and Programming Patterns

Rust via YouTube

Overview

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore Rust's approach to inheritance and object-oriented programming in this 44-minute conference talk by Valentin Tolmer. Dive into the concept of Traits as an alternative to traditional inheritance, learning how to implement common programming patterns using this powerful Rust feature. Discover the differences between dynamic and static dispatch, understand associated types, and examine practical examples like the Iterator trait. Gain insights into complex topics such as returning complex types, the orphan rule, downcasting, and auto traits. Follow along with the provided slides to enhance your understanding of Rust's unique approach to code organization and reuse.

Syllabus

Intro
How does Java do it?
How does C++ do it?
How does Rust do it?
Rust Traits
How to use Traits: dynamic dispatch
How to use Traits: static dispatch
Examples of traits
Associated types
Example Iterator
Returning complex types
Why can't I print a vector?
The orphan rule
Downcasting: Create a new trait
Auto traits
Conclusion

Taught by

Rust

Reviews

Start your review of How Not to Rely on Inheritance in Rust - Traits and Programming Patterns

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.