From 001fad3145a24941fe31783d0c4666ab90085816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 20 Feb 2021 12:14:24 +0100 Subject: [PATCH] remove "unsafe unwraps" --- src/database.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/database.rs b/src/database.rs index 31c1b21..2cdb040 100644 --- a/src/database.rs +++ b/src/database.rs @@ -78,12 +78,14 @@ impl EntryValue { } } -// unsafe unwraps! impl std::fmt::Display for EntryValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let (entry_type, entry_value) = match self { EntryValue::Address(address) => ("ADDRESS", address.to_string()), - EntryValue::Value(value) => ("VALUE", serde_json::to_string(value).unwrap()), + EntryValue::Value(value) => ( + "VALUE", + serde_json::to_string(value).unwrap_or_else(|_| String::from("?!?!?!")), + ), EntryValue::Invalid => ("INVALID", "INVALID".to_string()), }; write!(f, "{}: {}", entry_type, entry_value)