Enter your book access code

The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).

Don’t have the book yet? The landing page stays open — purchase unlocks this gym.

intermediate · order 60

Associated type vs type parameter

trait-assoc-01Related book chapters: 10 (optional — this page is complete on its own)associated-type

Slug: trait-assoc-01 · Paired reading: Chapter 10

Prompt

Define trait Parser { type Output; fn parse(&self, s: &str) -> Option<Self::Output>; } and struct I32Parser with Output = i32. Associated type: the impl chooses Output (one per impl).