1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::Span;
use std::borrow::Cow;

#[derive(Debug, PartialEq)]
pub struct Annotation {
    message: Cow<'static, str>,
    span: Span,
}

impl Annotation {
    pub fn new(message: impl Into<Cow<'static, str>>, span: Span) -> Self {
        Self {
            message: message.into(),
            span,
        }
    }

    pub fn message(&self) -> &str {
        self.message.as_ref()
    }

    pub fn span(&self) -> &Span {
        &self.span
    }
}