diff --git a/src/utils.rs b/src/utils.rs index 65adab67..f80ff0ef 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -30,14 +30,17 @@ impl Diagnostic for DiagnosticError { } } +/** +Convenience trait that adds a `.into_diagnostic()` method that converts a type to a `Result`. +*/ pub trait IntoDiagnostic { /// Converts [Result]-like types that return regular errors into a /// `Result` that returns a [Diagnostic]. - fn into_diagnostic(self, code: &(dyn fmt::Display)) -> Result; + fn into_diagnostic(self, code: impl fmt::Display) -> Result; } impl IntoDiagnostic for Result { - fn into_diagnostic(self, code: &(dyn fmt::Display)) -> Result { + fn into_diagnostic(self, code: impl fmt::Display) -> Result { self.map_err(|e| DiagnosticError { error: Box::new(e), code: format!("{}", code),