From 6d77483ad5cf66c054fa07379b2fe27a74e011f7 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Sun, 17 Oct 2021 19:56:40 +0200 Subject: [PATCH] Implement Default for ColorOptions --- src/config.rs | 2 +- src/main.rs | 2 +- src/types.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 758147a..2f5f62f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -85,7 +85,7 @@ impl Default for RawStyle { italic: false, } } -} // impl RawStyle +} impl From for Style { fn from(raw_style: RawStyle) -> Self { diff --git a/src/main.rs b/src/main.rs index 03277dc..92787de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -385,7 +385,7 @@ fn main() { #[cfg(not(target_os = "windows"))] let ansi_support = true; - let enable_styles = match args.color.unwrap_or(ColorOptions::Auto) { + let enable_styles = match args.color.unwrap_or_default() { // Attempt to use styling if instructed ColorOptions::Always => true, // Enable styling if: diff --git a/src/types.rs b/src/types.rs index 2d938a5..239b3fc 100644 --- a/src/types.rs +++ b/src/types.rs @@ -66,6 +66,12 @@ impl str::FromStr for ColorOptions { } } +impl Default for ColorOptions { + fn default() -> Self { + Self::Auto + } +} + #[derive(Debug, Eq, PartialEq)] pub enum LineType { Empty,