Traits
Checkpoints
- Associated Types Essential An *associated type* is a type member declared inside a trait that each implementor picks once. You'll see why `Iterator` uses `type Item;` instead of a type parameter, when an associated type is the right tool versus a generic parameter, and how this avoids the combinatorial explosion of having to write `Iterator<i32>`, `Iterator<String>`, and so on at every call site.
- Generic Traits and Trait Bounds Essential How to parametrise a trait with type parameters (`trait Convert<T>`), and how to constrain a generic function or type with a *trait bound* (`fn print<T: Display>(x: T)`). You'll see why trait bounds make generic code expressive without sacrificing static type checking, and how multiple bounds combine with `+` and `where`.
- Traits Essential A *trait* in Rust is a named set of methods that a type can promise to provide. You'll see how to declare a trait, how to implement one for a type with `impl Trait for Type`, the orphan rule that keeps implementations coherent, and why traits are Rust's answer to interfaces, type classes, and abstract base classes from other languages.