use ariadne::ReportBuilder;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Context<S> {
Label(ariadne::Label<S>),
Note(Box<str>),
Help(Box<str>),
}
impl<S> Context<S> {
pub fn new_note(note: impl ToString) -> Self {
Self::new_note_owned(note.to_string())
}
pub fn new_note_owned(note: String) -> Self {
Self::Note(note.into_boxed_str())
}
pub fn new_help(help: impl ToString) -> Self {
Self::new_help_owned(help.to_string())
}
pub fn new_help_owned(help: String) -> Self {
Self::Help(help.into_boxed_str())
}
pub(super) fn add_to_report_builder(self, builder: &mut ReportBuilder<S>)
where
S: ariadne::Span,
{
match self {
Self::Label(label) => builder.add_label(label),
Self::Note(note) => builder.add_note(note),
Self::Help(help) => builder.add_help(help),
}
}
}