Skip to content

Commit

Permalink
feat(error): impl AsRef<dyn StdError> for Report
Browse files Browse the repository at this point in the history
This seems like an easy implementation to fill out, and will be used for
tests in the following commit.
  • Loading branch information
sunshowers authored and zkat committed Oct 25, 2022
1 parent 3fc5c04 commit 1a27033
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/eyreish/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,18 @@ impl AsRef<dyn Diagnostic> for Report {
}
}

impl AsRef<dyn StdError + Send + Sync> for Report {
fn as_ref(&self) -> &(dyn StdError + Send + Sync + 'static) {
unsafe { ErrorImpl::error(self.inner.by_ref()) }
}
}

impl AsRef<dyn StdError> for Report {
fn as_ref(&self) -> &(dyn StdError + 'static) {
unsafe { ErrorImpl::error(self.inner.by_ref()) }
}
}

impl std::borrow::Borrow<dyn Diagnostic> for Report {
fn borrow(&self) -> &(dyn Diagnostic + 'static) {
self.as_ref()
Expand Down

0 comments on commit 1a27033

Please sign in to comment.