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

Implement std conversion traits for Writer when appropriate #51

Closed
jFransham opened this issue Sep 26, 2016 · 2 comments
Closed

Implement std conversion traits for Writer when appropriate #51

jFransham opened this issue Sep 26, 2016 · 2 comments

Comments

@jFransham
Copy link

jFransham commented Sep 26, 2016

Writer<Vec<u8>> could trivially implement Into<String>, Into<Vec<u8>>, AsRef<str> and AsRef<[u8]>, but doesn't. This would be good for generic programming, since taking an &T where T: AsRef<Foo>, or a T where T: Into<Foo> are extremely commmon idioms in Rust.

@jFransham jFransham changed the title Implement Into/AsRef for Writer when appropriate Implement std conversion traits for Writer when appropriate Sep 26, 2016
@BurntSushi
Copy link
Owner

I actually disagree with implementing the Into traits, since that requires the writer to not flush its internal buffer or to flush the buffer and ignore the error or to flush the buffer and panic on error.

Could you expand on the use cases for adding these APIs (including AsRef)?

@BurntSushi
Copy link
Owner

I'm going to close this. If there are specific concrete use cases for these, then we can revisit it, but I'm generally opposed to "add a bunch of generics because we can" style of API design.

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

No branches or pull requests

2 participants