From 4479f340d71717d7b420190757a04abad8b6f2ca Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 9 Feb 2024 14:23:41 -0500 Subject: [PATCH] Add From implementation for RwLockError --- src/error/rw_lock_error.rs | 11 ++++++++++- src/value/map.rs | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/error/rw_lock_error.rs b/src/error/rw_lock_error.rs index f0938c9..9ad0a7c 100644 --- a/src/error/rw_lock_error.rs +++ b/src/error/rw_lock_error.rs @@ -1,4 +1,7 @@ -use std::fmt::{self, Debug, Display, Formatter}; +use std::{ + fmt::{self, Debug, Display, Formatter}, + sync::PoisonError, +}; use serde::{Deserialize, Serialize}; @@ -19,3 +22,9 @@ impl Debug for RwLockError { write!(f, "{self}") } } + +impl From> for RwLockError { + fn from(_: PoisonError) -> Self { + RwLockError + } +} diff --git a/src/value/map.rs b/src/value/map.rs index 4c280e6..10763f8 100644 --- a/src/value/map.rs +++ b/src/value/map.rs @@ -88,8 +88,7 @@ impl Map { let value_type = value.r#type(); let previous = self .variables - .write() - .map_err(|_| RwLockError)? + .write()? .insert(key, (value, value_type.clone())); Ok(previous)