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.

beginner · order 7

Pushing through a moved Vec

own-move-05Related book chapters: 5 (optional — this page is complete on its own)ownershipVec

Slug: own-move-05 · Paired reading: Chapter 5

Prompt

fn append_then_len(mut v: Vec<i32>, x: i32) -> (Vec<i32>, usize) — push x, return the vec and its length. The caller must receive ownership back; they cannot use a moved-away v.