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

A function takes Cow<str> and conditionally uppercases it. For an input that needs NO modification, what is the performance benefit of Cow here?

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