How Not to Rely on Inheritance in Rust - Traits and Programming Patterns
Offered By: Rust via YouTube
Course Description
Overview
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
Related Courses
Introduction à la programmation orientée objet (en Java)École Polytechnique Fédérale de Lausanne via Coursera C++ For C Programmers, Part A
University of California, Santa Cruz via Coursera Introduction to Programming for Musicians and Digital Artists
California Institute of the Arts via Coursera Beginning Game Programming with C#
University of Colorado System via Coursera Paradigms of Computer Programming
Université catholique de Louvain via edX