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

Google, IBM & Meta Certificates – 40% Off
One Coursera Plus subscription covers most Professional Certificates on Coursera.
Unlock All Certificates
This talk explains how Rust uses traits in place of inheritance and demonstrates common patterns, including static and dynamic dispatch, associated types, iterators, and downcasting. It also compares how Java and C++ handle inheritance.

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.