From e35a63a9928b41eb59e914fb8db0c48a1dfccb53 Mon Sep 17 00:00:00 2001 From: Gavrilikhin Daniil Date: Sun, 7 May 2023 09:22:40 +0800 Subject: [PATCH] description -> message --- src/miette_diagnostic.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/miette_diagnostic.rs b/src/miette_diagnostic.rs index 5abf15c..25c6529 100644 --- a/src/miette_diagnostic.rs +++ b/src/miette_diagnostic.rs @@ -8,8 +8,8 @@ use crate::{Diagnostic, LabeledSpan, Severity}; /// Diagnostic that can be created at runtime. #[derive(Debug, Clone, PartialEq, Eq)] pub struct MietteDiagnostic { - /// Displayed diagnostic description - pub description: String, + /// Displayed diagnostic message + pub message: String, /// Unique diagnostic code to look up more information /// about this Diagnostic. Ideally also globally unique, and documented /// in the toplevel crate's documentation for easy searching. @@ -31,7 +31,7 @@ pub struct MietteDiagnostic { impl Display for MietteDiagnostic { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", &self.description) + write!(f, "{}", &self.message) } } @@ -73,7 +73,7 @@ impl Diagnostic for MietteDiagnostic { } impl MietteDiagnostic { - /// Create a new dynamic diagnostic with the given description. + /// Create a new dynamic diagnostic with the given message. /// /// # Examples /// ``` @@ -81,11 +81,11 @@ impl MietteDiagnostic { /// /// 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!"); + /// assert_eq!(diag.message, "Oops, something went wrong!"); /// ``` - pub fn new(description: impl Into) -> Self { + pub fn new(message: impl Into) -> Self { Self { - description: description.into(), + message: message.into(), labels: None, severity: None, code: None, @@ -101,7 +101,7 @@ impl MietteDiagnostic { /// use miette::{Diagnostic, MietteDiagnostic}; /// /// let diag = MietteDiagnostic::new("Oops, something went wrong!").with_code("foo::bar::baz"); - /// assert_eq!(diag.description, "Oops, something went wrong!"); + /// assert_eq!(diag.message, "Oops, something went wrong!"); /// assert_eq!(diag.code, Some("foo::bar::baz".to_string())); /// ``` pub fn with_code(self, code: impl Into) -> Self { @@ -118,7 +118,7 @@ impl MietteDiagnostic { /// use miette::{Diagnostic, MietteDiagnostic, Severity}; /// /// let diag = MietteDiagnostic::new("I warn you to stop!").with_severity(Severity::Warning); - /// assert_eq!(diag.description, "I warn you to stop!"); + /// assert_eq!(diag.message, "I warn you to stop!"); /// assert_eq!(diag.severity, Some(Severity::Warning)); /// ``` pub fn with_severity(self, severity: Severity) -> Self { @@ -135,7 +135,7 @@ impl MietteDiagnostic { /// use miette::{Diagnostic, MietteDiagnostic}; /// /// let diag = MietteDiagnostic::new("PC is not working").with_help("Try to reboot it again"); - /// assert_eq!(diag.description, "PC is not working"); + /// assert_eq!(diag.message, "PC is not working"); /// assert_eq!(diag.help, Some("Try to reboot it again".to_string())); /// ``` pub fn with_help(self, help: impl Into) -> Self { @@ -153,7 +153,7 @@ impl MietteDiagnostic { /// /// let diag = MietteDiagnostic::new("PC is not working") /// .with_url("https://letmegooglethat.com/?q=Why+my+pc+doesn%27t+work"); - /// assert_eq!(diag.description, "PC is not working"); + /// assert_eq!(diag.message, "PC is not working"); /// assert_eq!( /// diag.url, /// Some("https://letmegooglethat.com/?q=Why+my+pc+doesn%27t+work".to_string()) @@ -178,7 +178,7 @@ impl MietteDiagnostic { /// /// let label = LabeledSpan::at(0..3, "This should be Rust"); /// let diag = MietteDiagnostic::new("Wrong best language").with_label(label.clone()); - /// assert_eq!(diag.description, "Wrong best language"); + /// assert_eq!(diag.message, "Wrong best language"); /// assert_eq!(diag.labels, Some(vec![label])); /// ``` pub fn with_label(self, label: impl Into) -> Self { @@ -203,7 +203,7 @@ impl MietteDiagnostic { /// LabeledSpan::at_offset(6, "add 'r'"), /// ]; /// let diag = MietteDiagnostic::new("Typos in 'hello world'").with_labels(labels.clone()); - /// assert_eq!(diag.description, "Typos in 'hello world'"); + /// assert_eq!(diag.message, "Typos in 'hello world'"); /// assert_eq!(diag.labels, Some(labels)); /// ``` pub fn with_labels(self, labels: Vec) -> Self {