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 46

Cow for maybe-owned strings

own-cow-01Related book chapters: 5, 11 (optional — this page is complete on its own)Cow

Slug: own-cow-01 · Paired reading: Chapters 5 and 11

Prompt

fn normalize(s: &str) -> Cow<'_, str> — if s is already lowercase ASCII, return Cow::Borrowed(s); otherwise return an owned lowercased String as Cow::Owned.