1 use annotate_snippets
::{
2 display_list
::{DisplayList, FormatOptions}
,
3 snippet
::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}
,
7 let snippet
= Snippet
{
9 source
: r
#") -> Option<String> {
10 for ann in annotations {
11 match (ann.range.0, ann.range.1) {
12 (None, None) => continue,
13 (Some(start), Some(end)) if start > end_index => continue,
14 (Some(start), Some(end)) if start >= start_index => {
15 let label = if let Some(ref label) = ann.label {
23 " ".repeat(start - start_index),
24 "^".repeat(end - start),
32 origin
: Some("src/format.rs"),
36 label
: "expected `Option<String>` because of return type",
37 annotation_type
: AnnotationType
::Warning
,
41 label
: "expected enum `std::option::Option`",
42 annotation_type
: AnnotationType
::Error
,
47 title
: Some(Annotation
{
48 label
: Some("mismatched types"),
50 annotation_type
: AnnotationType
::Error
,
59 let dl
= DisplayList
::from(snippet
);