I’ve found myself recently hitting places where I had an Option<T> and wanted to pass some other component either a reference to the value in the Some case, or a newly-made default in the other case. This is a great time to use Cow, but the resulting code seems more verbose than the use-case demands:
let foo: Option<String> = Some("hello".into());
foo
.as_ref()
.map(Cow::Borrowed)
.unwrap_or_else(|| Cow::Owned("hi".into()));
// or
foo.as_ref().map_or_else(|| Cow::Owned("hi".into()), Cow::Borrowed);
Proposed New API
Add borrow_or_else<'a, F>(&'a self, f: F) -> Cow<'a, T>, which returns Cow::Borrowed if self was Some, and Cow::Owned if it was None. Similarly, add borrow_or<'a>(&self, fallback: T) -> Cow<'a, T> and borrow_or_default<'a>(&'a self) -> Cow<'a, T> where T : Default.