Slug: opt-let-else-01 · Paired reading: Chapter 2
Prompt
fn first_even(nums: &[i32]) -> Option<i32> — use let Some(n) = ... else { return None }; style (or equivalent) to pull the first even
value without nested match pyramids.
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.
beginner · order 15
Slug: opt-let-else-01 · Paired reading: Chapter 2
fn first_even(nums: &[i32]) -> Option<i32> — use let Some(n) = ... else { return None }; style (or equivalent) to pull the first even
value without nested match pyramids.