TUSST — the Stroop SigilTUSST
journeyforgecampaignadvanced
sign in
‹ advanced path

Traits, Generics & Dispatch

How Rust reuses code without inheritance. Bounds, associated types, blanket impls, and the real cost difference between a generic and a dyn Trait.

serves: Rust/C++ systems programming7 lessons · ~4h
progress0/7
Start track

// lessons

  1. 01

    Defining & Implementing a Trait

    Write a trait with a default method and override it.

  2. 02

    Trait Bounds & where Clauses

    Constrain a generic so the body compiles, without over-constraining it.

  3. 03

    Associated Types vs Generic Parameters

    Choose correctly between them, and say why Iterator uses one and not the other.

  4. 04

    Static Dispatch & Monomorphization

    Explain what the compiler emits for a generic function, and what it costs.

  5. 05

    Trait Objects & the Vtable

    Store mixed types behind Box<dyn Trait> and name the runtime cost.

  6. 06

    Object Safety

    Predict which traits can become trait objects before the compiler tells you.

  7. 07

    Blanket Impls & the Orphan Rule

    Implement a trait for every type that satisfies a bound — and know when you may not.

Every exercise compiles and runs in the Forge sandbox — standard library only, no external crates.

TUSST · The Ultimate Stellar Supreme Tutorial

learn rust → master stellar · open-source