From 43d16025d22c332576888d70d59d418b8c132fc6 Mon Sep 17 00:00:00 2001 From: Juan Eugenio Abadie Date: Fri, 30 Oct 2020 08:49:31 -0300 Subject: [PATCH] Reduce lines of code --- src/parser.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index c0be31f..80320a5 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -149,9 +149,7 @@ pub fn read_lines( } // tag else if line.starts_with('%') { - if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { - should_break = true - } + should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err(); snippet = String::from(""); tags = without_prefix(&line); } @@ -165,17 +163,13 @@ pub fn read_lines( } // comment else if line.starts_with('#') { - if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { - should_break = true - } + should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err(); snippet = String::from(""); comment = without_prefix(&line); } // variable else if line.starts_with('$') { - if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { - should_break = true - } + should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err(); snippet = String::from(""); let (variable, command, opts) = parse_variable_line(&line) .with_context(|| format!("Failed to parse variable line. See line number {} in cheatsheet `{}`", line_nr + 1, id))?;