remove "unsafe unwraps"

feat/vaults
Tomáš Mládek 2021-02-20 12:14:24 +01:00 committed by Tomáš Mládek
parent c0e1f42533
commit 001fad3145
1 changed files with 4 additions and 2 deletions

View File

@ -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)