diff --git a/src/options.rs b/src/options.rs index 8c5bc845..d24a8939 100644 --- a/src/options.rs +++ b/src/options.rs @@ -137,20 +137,17 @@ pub enum Colors { } impl Colors { - fn forced_value(&self) -> Option { + /// If colors were forced on or off by the user through an option or + /// environment variable, return that value. + /// + /// Otherwise, return None, meaning we should decide based on the + /// detected terminal characteristics. + pub fn forced_value(&self) -> Option { // From https://bixense.com/clicolors/ if env::var("NO_COLOR").map_or(false, |x| x != "0") { Some(false) } else if env::var("CLICOLOR_FORCE").map_or(false, |x| x != "0") { Some(true) - } else { - None - } - } - - pub fn active(&self) -> Option { - if let Some(active) = self.forced_value() { - Some(active) } else { match self { Colors::Always => Some(true), @@ -161,7 +158,8 @@ impl Colors { } pub fn active_stdout(&self) -> bool { - self.active().unwrap_or_else(::console::colors_enabled) + self.forced_value() + .unwrap_or_else(::console::colors_enabled) } } diff --git a/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap b/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap index e101c240..239c0353 100644 --- a/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap +++ b/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap @@ -212,9 +212,6 @@ src/options.rs: replace Colors::forced_value -> Option with Some(true) src/options.rs: replace Colors::forced_value -> Option with Some(false) src/options.rs: replace != with == in Colors::forced_value src/options.rs: replace != with == in Colors::forced_value -src/options.rs: replace Colors::active -> Option with None -src/options.rs: replace Colors::active -> Option with Some(true) -src/options.rs: replace Colors::active -> Option with Some(false) src/options.rs: replace Colors::active_stdout -> bool with true src/options.rs: replace Colors::active_stdout -> bool with false src/options.rs: replace or_slices -> &'c[T] with Vec::leak(Vec::new())