From cdc5ee36d2c7c6bc6ecc9676ebaa408066a9eb5a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 27 Jul 2020 22:16:34 +0800 Subject: refactor --- src/aggregate.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/aggregate.rs b/src/aggregate.rs index 45df81a..92e2416 100644 --- a/src/aggregate.rs +++ b/src/aggregate.rs @@ -117,14 +117,6 @@ fn path_color_of(path: impl AsRef) -> Option { } } -fn colorize_path(path: &Path, path_color: Option) -> colored::ColoredString { - if let Some(path_color) = path_color { - path.display().to_string().as_str().color(path_color) - } else { - path.display().to_string().as_str().normal() - } -} - fn output_colored_path( out: &mut impl io::Write, options: &WalkOptions, @@ -142,7 +134,13 @@ fn output_colored_path( .to_string() .as_str() .green(), - colorize_path(path.as_ref(), path_color), + { + let path = path.as_ref().display().to_string(); + match path_color { + Some(color) => path.color(color), + None => path.normal(), + } + }, if num_errors == 0 { Cow::Borrowed("") } else { -- cgit v1.2.3