Add From implementation for RwLockError

This commit is contained in:
Jeff 2024-02-09 14:23:41 -05:00
parent 9ef82df3a7
commit 4479f340d7
2 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,7 @@
use std::fmt::{self, Debug, Display, Formatter}; use std::{
fmt::{self, Debug, Display, Formatter},
sync::PoisonError,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -19,3 +22,9 @@ impl Debug for RwLockError {
write!(f, "{self}") write!(f, "{self}")
} }
} }
impl<T> From<PoisonError<T>> for RwLockError {
fn from(_: PoisonError<T>) -> Self {
RwLockError
}
}

View File

@ -88,8 +88,7 @@ impl Map {
let value_type = value.r#type(); let value_type = value.r#type();
let previous = self let previous = self
.variables .variables
.write() .write()?
.map_err(|_| RwLockError)?
.insert(key, (value, value_type.clone())); .insert(key, (value, value_type.clone()));
Ok(previous) Ok(previous)