Slug: own-move-06 · Paired reading: Chapters 5 and 9
Prompt
fn sum_consuming(v: Vec<i32>) -> i32 — sum via into_iter (moves
elements out). Contrast: borrowing with iter would leave v usable;
consuming does not.
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? Get it on Amazon (US and other storefronts linked in the site footer) — the Preface access code unlocks this gym.
beginner · order 8
Slug: own-move-06 · Paired reading: Chapters 5 and 9
fn sum_consuming(v: Vec<i32>) -> i32 — sum via into_iter (moves
elements out). Contrast: borrowing with iter would leave v usable;
consuming does not.