Skip to main content

ocelot_base/
source_annotation.rs

1use crate::shared_string::SharedString;
2use crate::span::Span;
3
4/// Message attached to one highlighted source span.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct SourceAnnotation {
7    /// Byte span highlighted by this annotation.
8    pub span: Span,
9    /// User-facing annotation message.
10    pub message: SharedString,
11}
12
13impl SourceAnnotation {
14    /// Creates a source annotation from its span and message.
15    pub fn new(span: Span, message: impl Into<SharedString>) -> Self {
16        Self {
17            span,
18            message: message.into(),
19        }
20    }
21}