diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-27 22:16:34 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-27 22:16:34 +0800 |
commit | cdc5ee36d2c7c6bc6ecc9676ebaa408066a9eb5a (patch) | |
tree | 6f542fe93311a9376b899e92adeb394f9c9250ee | |
parent | 4d2e83904fd66a3d480b5f50ad6fa2192d113a3f (diff) |
refactor
-rw-r--r-- | src/aggregate.rs | 16 |
1 files 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<Path>) -> Option<Color> { } } -fn colorize_path(path: &Path, path_color: Option<colored::Color>) -> 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 { |