Learn Generative AI, Prompt Engineering, and LLMs for Free
AI Engineer - Learn how to integrate AI into software applications
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