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);