From 5e75370a67a631c3d016364c03e59b3679c08441 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sun, 21 Nov 2021 22:01:34 -0600 Subject: [PATCH] Properly deserialize tags if null --- src/event.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/event.rs b/src/event.rs index ec0f59a..5cf27c0 100644 --- a/src/event.rs +++ b/src/event.rs @@ -19,12 +19,13 @@ pub struct Event { type Tag = Vec>; +// handle a default value (empty vec) for null tags fn tag_from_string<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { - let s: Option = Deserialize::deserialize(deserializer)?; - Ok(vec![]) + let opt = Option::deserialize(deserializer)?; + Ok(opt.unwrap_or_else(|| vec![])) } fn u32_from_string<'de, D>(deserializer: D) -> Result