Slug: borrow-excl-04 · Paired reading: Chapter 6
Prompt
fn swap_ends(v: &mut [i32]) — swap first and last when len ≥ 2.
Use a short exclusive region (indexes / swap) so you don't hold two
overlapping &mut to the same slice.
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 34
Slug: borrow-excl-04 · Paired reading: Chapter 6
fn swap_ends(v: &mut [i32]) — swap first and last when len ≥ 2.
Use a short exclusive region (indexes / swap) so you don't hold two
overlapping &mut to the same slice.