typeover
rust curriculum

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

Traits describe behavior a type provides. They feel partly like TypeScript interfaces, but implementation is explicit and coherence rules decide where impls may live. Planned exerc…

9 ready

begin →

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…

9 ready

begin →

Rust generics are monomorphized and usually constrained with traits. TypeScript's generic syntax transfers conceptually, but Rust wants bounds where behavior is used. Planned exerc…

9 ready

begin →

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…

9 ready

begin →