Generic Functions over Traits
Write one function for many types.
One Function, Many Types
The real power of traits is generic code: write a function once and it works for every conforming type. 🚀
A Trait as a Bound
You use a trait as a bound on a generic parameter, promising the type has the methods you call.
All lessons in this course
- What Is a Trait?
- Conforming a Struct to a Trait
- Built-in Traits Like Copyable
- Generic Functions over Traits