feat(report): `Report::new_boxed`

This is already currently accessible with `miette!`, but I missed that
because it isn't clearly documented. Add a constructor to mirror
`Report::new` and `Report::msg`.
This commit is contained in:
Rain 2022-10-24 14:39:19 -07:00
parent 5815eab310
commit aee218757b
1 changed files with 12 additions and 0 deletions

View File

@ -73,6 +73,18 @@ impl Report {
Report::from_adhoc(message)
}
/// Create a new error object from a boxed [`Diagnostic`].
///
/// The boxed type must be thread safe and 'static, so that the `Report`
/// will be as well.
///
/// Boxed `Diagnostic`s don't implement `Diagnostic` themselves due to trait coherence issues.
/// This method allows you to create a `Report` from a boxed `Diagnostic`.
#[cfg_attr(track_caller, track_caller)]
pub fn new_boxed(error: Box<dyn Diagnostic + Send + Sync + 'static>) -> Self {
Report::from_boxed(error)
}
#[cfg_attr(track_caller, track_caller)]
pub(crate) fn from_std<E>(error: E) -> Self
where