Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustCow clone-on-writeSingle-choice MCQ

In this `Cow` function, when does an allocation (a clone) actually occur?

use std::borrow::Cow; fn normalize(input: &str) -> Cow<str> { if input.contains(' ') { Cow::Owned(input.replace(' ', "_")) } else { Cow::Borrowed(input) } }