fix: Remove an unwrap (#35)

* chore: Remove an unwrap

* chore: convert to a potential error instead, older api

* chore: format file
This commit is contained in:
J M
2022-06-06 09:49:11 -06:00
committed by GitHub
parent 6f6c26acd4
commit 8e7c893d48

View File

@@ -121,7 +121,11 @@ where
self.set_(db_handle, new_value, &[]).await
}
pub async fn get<DH: DbHandle>(&self, db_handle: &mut DH) -> Result<T, Error> {
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<T> LockReceipt<T, String>