Curriculum Traits & generics
module 6 of 7
Traits & generics
Rust's abstraction toolkit. Traits, trait bounds, derives, generic functions and types, associated types, impl Trait, and when dynamic dispatch with trait objects is the right tradeoff.
Themes
Rust leans on a small set of common traits: Debug, Clone, Copy,
Default, PartialEq, Eq, PartialOrd, Ord, and Hash. Derive
is the idiomatic way to ask the compiler…
Rust has two styles of polymorphism: static dispatch with generics or
impl Trait, and dynamic dispatch with dyn Trait. This theme teaches
when each is appropriate and why trait…