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 24

forget is safe — and still a choice

own-fn-06Related book chapters: 5 (optional — this page is complete on its own)mem-forgetleak

Slug: own-fn-06 · Paired reading: Chapter 5

Prompt

Bomb increments a shared Cell<usize> counter in Drop. fn drop_counts(n: usize) -> usize creates n bombs and drops them normally. fn forget_counts(n: usize) -> usize creates n bombs and mem::forgets each — Drop must not run. Return the counter value.