Write an `Into<anstream::ColorChoice>` implementation for more idiomatic code (#1064)

Follow-up to #1049
This commit is contained in:
Zanie Blue 2024-01-23 09:43:16 -06:00 committed by GitHub
parent 1131341cbc
commit 1f0a21d127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -87,12 +87,12 @@ pub enum ColorChoice {
Never, Never,
} }
impl ColorChoice { impl From<ColorChoice> for anstream::ColorChoice {
fn to_anstream(&self) -> anstream::ColorChoice { fn from(value: ColorChoice) -> Self {
match self { match value {
Self::Auto => anstream::ColorChoice::Auto, ColorChoice::Auto => anstream::ColorChoice::Auto,
Self::Always => anstream::ColorChoice::Always, ColorChoice::Always => anstream::ColorChoice::Always,
Self::Never => anstream::ColorChoice::Never, ColorChoice::Never => anstream::ColorChoice::Never,
} }
} }
} }
@ -599,7 +599,7 @@ async fn inner() -> Result<ExitStatus> {
if cli.no_color { if cli.no_color {
anstream::ColorChoice::write_global(anstream::ColorChoice::Never); anstream::ColorChoice::write_global(anstream::ColorChoice::Never);
} else { } else {
anstream::ColorChoice::write_global(cli.color.to_anstream()); anstream::ColorChoice::write_global(cli.color.into());
} }
miette::set_hook(Box::new(|_| { miette::set_hook(Box::new(|_| {