scrap
scrap copied to clipboard
Display names.
trafficstars
fn Display::name(&self) -> &str;
Or maybe it should be:
fn Display::name(&self) -> Cow<str>;
What is the benefit of Cow string?
I've come across this article which shows how it's good for an API where it takes a string from the user. Not sure how it's useful when it's the other way around though?
It's useful because on macOS I'd need to allocate a string, but on Windows I wouldn't, and I think this is the best way to abstract over maybe allocating a string. I guess it could also be ... -> impl Into<String> + Borrow<str> or something like that, but that's more complicated.