diff options
-rw-r--r-- | cli/colors.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cli/colors.rs b/cli/colors.rs index 056a6e0d0..5afd773cd 100644 --- a/cli/colors.rs +++ b/cli/colors.rs @@ -35,11 +35,12 @@ pub fn enable_ansi() { } fn style(s: &str, colorspec: ColorSpec) -> impl fmt::Display { + if !use_color() { + return String::from(s); + } let mut v = Vec::new(); let mut ansi_writer = Ansi::new(&mut v); - if use_color() { - ansi_writer.set_color(&colorspec).unwrap(); - } + ansi_writer.set_color(&colorspec).unwrap(); ansi_writer.write_all(s.as_bytes()).unwrap(); ansi_writer.reset().unwrap(); String::from_utf8_lossy(&v).into_owned() |