Merge all Destination variants

This commit is contained in:
Oli Scherer 2023-07-26 18:26:24 +00:00
parent 826a8ef52e
commit 10da30f540

View File

@ -2604,7 +2604,6 @@ fn emit_to_destination(
}
pub enum Destination {
Terminal(StandardStream),
Raw(Box<(dyn WriteColor + Send)>),
}
@ -2649,7 +2648,7 @@ fn from_stderr(color: ColorConfig) -> Destination {
// On non-Windows we rely on the atomicity of `write` to ensure errors
// don't get all jumbled up.
if cfg!(windows) {
Terminal(StandardStream::stderr(choice))
Raw(Box::new(StandardStream::stderr(choice)))
} else {
let buffer_writer = BufferWriter::stderr(choice);
let buffer = buffer_writer.buffer();
@ -2659,14 +2658,12 @@ fn from_stderr(color: ColorConfig) -> Destination {
fn writable(&mut self) -> &mut dyn WriteColor {
match *self {
Destination::Terminal(ref mut t) => t,
Destination::Raw(ref mut t) => t,
}
}
fn supports_color(&self) -> bool {
match *self {
Self::Terminal(ref stream) => stream.supports_color(),
Self::Raw(ref writer) => writer.supports_color(),
}
}