From 8e7c893d48f03bb1a38b826b680ea77d0e109825 Mon Sep 17 00:00:00 2001 From: J M <2364004+Blu-J@users.noreply.github.com> Date: Mon, 6 Jun 2022 09:49:11 -0600 Subject: [PATCH] fix: Remove an unwrap (#35) * chore: Remove an unwrap * chore: convert to a potential error instead, older api * chore: format file --- patch-db/src/bulk_locks.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/patch-db/src/bulk_locks.rs b/patch-db/src/bulk_locks.rs index 7362592..c11a912 100644 --- a/patch-db/src/bulk_locks.rs +++ b/patch-db/src/bulk_locks.rs @@ -121,7 +121,11 @@ where self.set_(db_handle, new_value, &[]).await } pub async fn get(&self, db_handle: &mut DH) -> Result { - self.get_(db_handle, &[]).await.map(|x| x.unwrap()) + self.get_(db_handle, &[]).await.and_then(|x| { + x.map(Ok).unwrap_or_else(|| { + serde_json::from_value(serde_json::Value::Null).map_err(Error::JSON) + }) + }) } } impl LockReceipt