Skip to content

Commit

Permalink
Make durable::Error require that the error be Send + Sync
Browse files Browse the repository at this point in the history
While durable programs will never run on multiple threads it is much
easier to integrate the error type with external libraries if it is both
Send and Sync.
  • Loading branch information
swlynch99 committed Sep 4, 2024
1 parent 10faf20 commit b9a17b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/durable/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Error {
///
/// The error type must be '`static`, but there are no other restrictions on
/// it.
pub fn new<E: StdError + 'static>(error: E) -> Self {
pub fn new<E: StdError + Send + Sync + 'static>(error: E) -> Self {
error.into()
}

Expand Down Expand Up @@ -80,14 +80,14 @@ impl AsRef<dyn StdError> for Error {

impl<E> From<E> for Error
where
E: StdError + 'static,
E: StdError + Send + Sync + 'static,
{
fn from(error: E) -> Self {
Self(ErrorImpl(Box::new(error)))
}
}

struct ErrorImpl(Box<dyn StdError>);
struct ErrorImpl(Box<dyn StdError + Send + Sync>);

impl fmt::Debug for ErrorImpl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit b9a17b3

Please sign in to comment.