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 WriteColor for std::io::Sink #38

Merged
merged 1 commit into from Jun 9, 2021

Conversation

segeljakt
Copy link
Contributor

This PR addresses #37 by implementing WriteColor for std::io::Sink. A Sink is a writer which moves data into the void, and can be useful for when you want to measure the performance of a program without including I/O.

@segeljakt
Copy link
Contributor Author

segeljakt commented Jan 23, 2021

Would you like me to add a test?

src/lib.rs Outdated
@@ -1450,6 +1450,20 @@ impl<W: io::Write> Ansi<W> {
}
}

impl WriteColor for io::Sink {
fn supports_color(&self) -> bool {
true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be false? Why did you return true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure if there is ever a situation where you absolutely need a sink which supports color. I can change it to false.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would a sink that supports color look like? It never writes anything so it would seem to me that it can't support color?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, sorry I might have mistaken what support_color meant. I thought support_color meant you can write colored output to the sink without encountering any problems.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this LGTM, thanks!

@BurntSushi BurntSushi merged commit dc7e7b9 into BurntSushi:master Jun 9, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants