diff --git a/src/protocol.rs b/src/protocol.rs index 61b8a82..a26f2a5 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -12,7 +12,7 @@ use crate::MietteError; Adds rich metadata to your Error that can be used by [DiagnosticReporter] to print really nice and human-friendly error messages. */ -pub trait Diagnostic: std::error::Error + Send + Sync { +pub trait Diagnostic: std::error::Error { /// Unique diagnostic code that can be used to look up more information /// about this Diagnostic. Ideally also globally unique, and documented in /// the toplevel crate's documentation for easy searching. Rust path @@ -37,6 +37,14 @@ pub trait Diagnostic: std::error::Error + Send + Sync { } } +impl std::error::Error for Box {} + +impl From for Box { + fn from(diag: T) -> Self { + Box::new(diag) + } +} + /** Protocol for [Diagnostic] handlers, which are responsible for actually printing out Diagnostics.