[][src]Struct show_my_errors::Annotation

pub struct Annotation {
    pub header: Option<String>,
    pub text: Option<String>,
    pub severity: Severity,
    // some fields omitted
}

Info about annotation. You can create these manually and then pass to AnnotationList::add or just use AnnotationLists helper methods

Fields

header: Option<String>

header will be shown above error message

text: Option<String>

text will be shown near annotated fragment. Note that fragment will be highlighted even if text is None. To disable this, pass a zero length range when creating the annotation.

severity: Severity

Methods

impl Annotation[src]

pub fn new(
    range: Range<usize>,
    severity: Severity,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<Self>
[src]

Create new annotation. Will return Error::InvalidRange if provided range has start > end. You can pass &str, String or Option<String> as header and text arguments.

assert_eq!(
    Annotation::new(0..5, Severity::Info, "header", "text").unwrap(),
    Annotation::new(
        0..5, Severity::Info, Some("header".into()), Some("text".into())
    ).unwrap()
);
assert!(Annotation::new(0..5, Severity::Warning, None, None).is_ok());
assert_eq!(
    Annotation::new(5..0, Severity::Info, "h", "t"), Err(Error::InvalidRange(5, 0))
);

pub fn info(
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<Self>
[src]

Create a new Severity::Info annotation

pub fn warning(
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<Self>
[src]

Create a new Severity::Warning annotation

pub fn error(
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<Self>
[src]

Create a new Severity::Error annotation

pub fn range(&self) -> &Range<usize>[src]

Get annotations range

Trait Implementations

impl Clone for Annotation[src]

impl Debug for Annotation[src]

impl Eq for Annotation[src]

impl PartialEq<Annotation> for Annotation[src]

impl StructuralEq for Annotation[src]

impl StructuralPartialEq for Annotation[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.