Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display names. #16

Open
quadrupleslap opened this issue Apr 8, 2018 · 3 comments
Open

Display names. #16

quadrupleslap opened this issue Apr 8, 2018 · 3 comments

Comments

@quadrupleslap
Copy link
Owner

fn Display::name(&self) -> &str;
@quadrupleslap
Copy link
Owner Author

quadrupleslap commented Apr 11, 2018

Or maybe it should be:

fn Display::name(&self) -> Cow<str>;

@polarathene
Copy link

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?

@quadrupleslap
Copy link
Owner Author

quadrupleslap commented Apr 11, 2018

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.

Edit: Posted a question on the Rust user forums!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants