From ab20069e8513d62d24836b372b2c5103f0692461 Mon Sep 17 00:00:00 2001 From: Gavrilikhin Daniil Date: Sat, 6 May 2023 09:20:46 +0800 Subject: [PATCH] DynamicDiagnostic -> MietteDiagnostic --- src/lib.rs | 4 ++-- ...amic_diagnostic.rs => miette_diagnostic.rs} | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) rename src/{dynamic_diagnostic.rs => miette_diagnostic.rs} (79%) diff --git a/src/lib.rs b/src/lib.rs index c06f25d..576df49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -619,12 +619,12 @@ //! [`ariadne`](https://github.com/zesterer/ariadne), which is MIT licensed. pub use miette_derive::*; -pub use dynamic_diagnostic::*; pub use error::*; pub use eyreish::*; #[cfg(feature = "fancy-no-backtrace")] pub use handler::*; pub use handlers::*; +pub use miette_diagnostic::*; pub use named_source::*; #[cfg(feature = "fancy")] pub use panic::*; @@ -632,7 +632,6 @@ pub use protocol::*; mod chain; mod diagnostic_chain; -mod dynamic_diagnostic; mod error; mod eyreish; #[cfg(feature = "fancy-no-backtrace")] @@ -640,6 +639,7 @@ mod handler; mod handlers; #[doc(hidden)] pub mod macro_helpers; +mod miette_diagnostic; mod named_source; #[cfg(feature = "fancy")] mod panic; diff --git a/src/dynamic_diagnostic.rs b/src/miette_diagnostic.rs similarity index 79% rename from src/dynamic_diagnostic.rs rename to src/miette_diagnostic.rs index 87055b1..486ad6e 100644 --- a/src/dynamic_diagnostic.rs +++ b/src/miette_diagnostic.rs @@ -7,7 +7,7 @@ use crate::Diagnostic; /// Diagnostic that can be created at runtime. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct DynamicDiagnostic { +pub struct MietteDiagnostic { /// Displayed diagnostic description pub description: String, /// Unique diagnostic code to look up more information @@ -18,15 +18,15 @@ pub struct DynamicDiagnostic { pub code: Option, } -impl Display for DynamicDiagnostic { +impl Display for MietteDiagnostic { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", &self.description) } } -impl Error for DynamicDiagnostic {} +impl Error for MietteDiagnostic {} -impl Diagnostic for DynamicDiagnostic { +impl Diagnostic for MietteDiagnostic { fn code<'a>(&'a self) -> Option> { self.code .as_ref() @@ -35,14 +35,14 @@ impl Diagnostic for DynamicDiagnostic { } } -impl DynamicDiagnostic { +impl MietteDiagnostic { /// Create a new dynamic diagnostic with the given description. /// /// # Examples /// ``` - /// use miette::{Diagnostic, DynamicDiagnostic}; + /// use miette::{Diagnostic, MietteDiagnostic}; /// - /// let diag = DynamicDiagnostic::new("Oops, something went wrong!"); + /// let diag = MietteDiagnostic::new("Oops, something went wrong!"); /// assert_eq!(diag.to_string(), "Oops, something went wrong!"); /// assert_eq!(diag.description, "Oops, something went wrong!"); /// ``` @@ -57,9 +57,9 @@ impl DynamicDiagnostic { /// /// # Examples /// ``` - /// use miette::{Diagnostic, DynamicDiagnostic}; + /// use miette::{Diagnostic, MietteDiagnostic}; /// - /// let diag = DynamicDiagnostic::new("Oops, something went wrong!").with_code("foo::bar::baz"); + /// let diag = MietteDiagnostic::new("Oops, something went wrong!").with_code("foo::bar::baz"); /// assert_eq!(diag.description, "Oops, something went wrong!"); /// assert_eq!(diag.code, Some("foo::bar::baz".to_string())); /// ```