pub struct Annotation {
pub message: Option<String>,
pub kind: AnnotationKind,
pub span: Span,
}Expand description
An annotation associated with an issue, providing additional context or highlighting specific code spans.
Fields§
§message: Option<String>An optional message associated with the annotation.
kind: AnnotationKindThe kind of annotation.
span: SpanThe code span that the annotation refers to.
Implementations§
Source§impl Annotation
impl Annotation
Sourcepub fn new(kind: AnnotationKind, span: Span) -> Self
pub fn new(kind: AnnotationKind, span: Span) -> Self
Creates a new annotation with the given kind and span.
§Examples
use mago_reporting::{Annotation, AnnotationKind};
use mago_span::Span;
use mago_span::Position;
let start = Position::dummy(0);
let end = Position::dummy(5);
let span = Span::new(start, end);
let annotation = Annotation::new(AnnotationKind::Primary, span);Sourcepub fn primary(span: Span) -> Self
pub fn primary(span: Span) -> Self
Creates a new primary annotation with the given span.
§Examples
use mago_reporting::{Annotation, AnnotationKind};
use mago_span::Span;
use mago_span::Position;
let start = Position::dummy(0);
let end = Position::dummy(5);
let span = Span::new(start, end);
let annotation = Annotation::primary(span);Sourcepub fn secondary(span: Span) -> Self
pub fn secondary(span: Span) -> Self
Creates a new secondary annotation with the given span.
§Examples
use mago_reporting::{Annotation, AnnotationKind};
use mago_span::Span;
use mago_span::Position;
let start = Position::dummy(0);
let end = Position::dummy(5);
let span = Span::new(start, end);
let annotation = Annotation::secondary(span);Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Sets the message of this annotation.
§Examples
use mago_reporting::{Annotation, AnnotationKind};
use mago_span::Span;
use mago_span::Position;
let start = Position::dummy(0);
let end = Position::dummy(5);
let span = Span::new(start, end);
let annotation = Annotation::primary(span).with_message("This is a primary annotation");Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Returns true if this annotation is a primary annotation.
Trait Implementations§
Source§impl Clone for Annotation
impl Clone for Annotation
Source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Annotation
impl Debug for Annotation
Source§impl<'de> Deserialize<'de> for Annotation
impl<'de> Deserialize<'de> for Annotation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Annotation> for Label<SourceIdentifier>
impl From<Annotation> for Label<SourceIdentifier>
Source§fn from(annotation: Annotation) -> Label<SourceIdentifier>
fn from(annotation: Annotation) -> Label<SourceIdentifier>
Converts to this type from the input type.
Source§impl Hash for Annotation
impl Hash for Annotation
Source§impl Ord for Annotation
impl Ord for Annotation
Source§fn cmp(&self, other: &Annotation) -> Ordering
fn cmp(&self, other: &Annotation) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Annotation
impl PartialEq for Annotation
Source§impl PartialOrd for Annotation
impl PartialOrd for Annotation
Source§impl Serialize for Annotation
impl Serialize for Annotation
impl Eq for Annotation
impl StructuralPartialEq for Annotation
Auto Trait Implementations§
impl Freeze for Annotation
impl RefUnwindSafe for Annotation
impl Send for Annotation
impl Sync for Annotation
impl Unpin for Annotation
impl UnwindSafe for Annotation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more