From 5f07b4ea1fed7994414fdcc0abec5ae3a514d811 Mon Sep 17 00:00:00 2001 From: Stephen <stephen@stephendownward.ca> Date: Fri, 9 Oct 2020 21:18:38 -0300 Subject: [PATCH] Collapse nested if block --- src/lol.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lol.rs b/src/lol.rs index f03626e..54daf48 100644 --- a/src/lol.rs +++ b/src/lol.rs @@ -33,17 +33,14 @@ pub fn print_rainbow(line: &str, freq: f64, seed: f64, spread: f64, invert: bool { exit(0); } - } else { - if stdout() - .write_all( - format!("{}\x1B[{}m{}\x1B[39m", &c[1], color.to_fg_str(), &c[2]).as_bytes(), - ) - .is_err() - { - exit(0); - } + } else if stdout() + .write_all(format!("{}\x1B[{}m{}\x1B[39m", &c[1], color.to_fg_str(), &c[2]).as_bytes()) + .is_err() + { + exit(0); } } + if stdout().write_all(&[b'\n']).is_err() { exit(0); } -- GitLab