diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-03-06 12:26:57 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-03-06 12:26:57 +0100 |
commit | 85ed8053e5fd20902e156a120dadd3f418d52a1e (patch) | |
tree | 43409e7885d910a023bbd6c9a7885080674d1f01 | |
parent | 3cc1856d669eac8097fc064325d4fe53cbdb8175 (diff) | |
download | ezau-85ed8053e5fd20902e156a120dadd3f418d52a1e.tar.gz ezau-85ed8053e5fd20902e156a120dadd3f418d52a1e.tar.bz2 ezau-85ed8053e5fd20902e156a120dadd3f418d52a1e.zip |
don't parse empty categories
-rw-r--r-- | src/logbag.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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::<Vec<_>>(), ) }) + .filter(|(cat, lines)| !cat.is_empty() && !lines.is_empty()) .collect(); Ok(LogBag { data }) } @@ -147,6 +148,11 @@ mod test { } #[test] + fn parse_empty() { + assert_eq!(LogBag::parse_plain(""), Some(LogBag::new())); + } + + #[test] fn parse_single() { let mut logbag = LogBag::new(); logbag.insert("cat 1", "line 1".to_string()); |