Skip to content

Commit

Permalink
Make XmlError be Send and Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Dec 20, 2024
1 parent 1390d5c commit b86f2d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix a regression: make `Error` and `XmlError` be `Send` and `Sync` again [`#89`](https://github.com/rust-syndication/atom/pull/89)

## 0.12.5 - 2024-11-16

- Remove ambiguous statements about escaping from documentation. [`#85`](https://github.com/rust-syndication/atom/pull/85)
Expand Down
16 changes: 14 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ impl From<XmlError> for Error {
}

#[derive(Debug)]
pub struct XmlError(Box<dyn StdError>);
pub struct XmlError(Box<dyn StdError + Send + Sync>);

impl XmlError {
pub(crate) fn new(err: impl StdError + 'static) -> Self {
pub(crate) fn new(err: impl StdError + Send + Sync + 'static) -> Self {
Self(Box::new(err))
}
}
Expand All @@ -83,3 +83,15 @@ impl fmt::Display for XmlError {
fmt::Display::fmt(&self.0, f)
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn error_send_and_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Error>();
assert_send_sync::<XmlError>();
}
}

0 comments on commit b86f2d6

Please sign in to comment.