From dc18e650bb2b15bd761baef39337969d89668439 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 24 Apr 2018 21:07:10 +0200 Subject: [PATCH] Collapse nested if-else-if --- lib/core/libimagstore/src/util.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/core/libimagstore/src/util.rs b/lib/core/libimagstore/src/util.rs index e353d3f4..f09fecd8 100644 --- a/lib/core/libimagstore/src/util.rs +++ b/lib/core/libimagstore/src/util.rs @@ -52,16 +52,12 @@ pub fn entry_buffer_to_header_content(buf: &str) -> Result<(Value, String)> { if line == "---" && !header_consumed { header_consumed = true; // do not further process the line + } else if !header_consumed { + let _ = writeln!(header, "{}", line)?; + } else if iter.peek().is_some() { + let _ = writeln!(content, "{}", line)?; } else { - if !header_consumed { - let _ = writeln!(header, "{}", line)?; - } else { - if iter.peek().is_some() { - let _ = writeln!(content, "{}", line)?; - } else { - let _ = write!(content, "{}", line)?; - } - } + let _ = write!(content, "{}", line)?; } }