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.

advanced · order 179

Timed mixed screen A

capstone-01Related book chapters: 27, 29 (optional — this page is complete on its own)timedcapstone

Slug: capstone-01 · Paired reading: Chapters 27 and 29

Prompt

Combine Result parsing and a classic hash/two-pointer task: fn score_line(line: &str) -> Result<i32, &'static str> for ok:N / err:msg, and fn two_sum(nums: &[i32], target: i32) -> Option<(usize, usize)>.

Contract

  • score_line: ok:<i32>Ok; err:…Err("error line"); other → Err("bad format"); bad number → Err("bad number")
  • two_sum: first pair of indices (i, j) with i < j; empty / no pair → None