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 58

impl Trait return vs generic param

trait-impl-01Related book chapters: 10 (optional — this page is complete on its own)impl-Trait

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

Prompt

fn odds(nums: &[i32]) -> impl Iterator<Item = i32> + '_ — iterate odd values as owned i32s. impl Trait in return position hides the concrete iterator type from the caller.