From ffc2a0adb145b39b8d3e93cee9d2e7c82aae0f85 Mon Sep 17 00:00:00 2001 From: InfiniteCoder Date: Fri, 2 Feb 2024 19:23:55 +0300 Subject: [PATCH] Implement with_label & with_note --- codespan-reporting/src/diagnostic.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/codespan-reporting/src/diagnostic.rs b/codespan-reporting/src/diagnostic.rs index 8e3abf4f..93e8fcd8 100644 --- a/codespan-reporting/src/diagnostic.rs +++ b/codespan-reporting/src/diagnostic.rs @@ -177,12 +177,24 @@ impl Diagnostic { self } + /// Add a label to the diagnostic. + pub fn with_label(mut self, label: Label) -> Diagnostic { + self.labels.push(label); + self + } + /// Add some labels to the diagnostic. pub fn with_labels(mut self, mut labels: Vec>) -> Diagnostic { self.labels.append(&mut labels); self } + /// Add a note to the diagnostic. + pub fn with_note(mut self, note: impl ToString) -> Diagnostic { + self.notes.push(note.to_string()); + self + } + /// Add some notes to the diagnostic. pub fn with_notes(mut self, mut notes: Vec) -> Diagnostic { self.notes.append(&mut notes);