From 85ed8053e5fd20902e156a120dadd3f418d52a1e Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 6 Mar 2021 12:26:57 +0100 Subject: don't parse empty categories --- src/logbag.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/logbag.rs b/src/logbag.rs index b08098a..6575ecd 100644 --- a/src/logbag.rs +++ b/src/logbag.rs @@ -105,6 +105,7 @@ impl FromStr for LogBag { lines.map(ToString::to_string).collect::>(), ) }) + .filter(|(cat, lines)| !cat.is_empty() && !lines.is_empty()) .collect(); Ok(LogBag { data }) } @@ -146,6 +147,11 @@ mod test { ); } + #[test] + fn parse_empty() { + assert_eq!(LogBag::parse_plain(""), Some(LogBag::new())); + } + #[test] fn parse_single() { let mut logbag = LogBag::new(); -- cgit v1.2.3