Skip to content

Instantly share code, notes, and snippets.

@legendiguess
Created March 27, 2020 03:44
Show Gist options
  • Save legendiguess/ccb197dac4bc77e3ae7571befc8ffbe2 to your computer and use it in GitHub Desktop.
Save legendiguess/ccb197dac4bc77e3ae7571befc8ffbe2 to your computer and use it in GitHub Desktop.
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::display_list::FormatOptions;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
fn main() {
let snippet = Snippet {
title: Some(Annotation {
label: Some("er".to_string()),
id: None,
annotation_type: AnnotationType::Error,
}),
footer: vec![],
slices: vec![
Slice {
source: "fn main(): float {
t
}"
.to_string(),
line_start: 51,
origin: Some("src/format.rs".to_string()),
fold: false,
annotations: vec![SourceAnnotation {
label: "error here".to_string(),
annotation_type: AnnotationType::Error,
range: (21, 22),
}],
},
Slice {
source: "fn main(): float {
\tt
}"
.to_string(),
line_start: 51,
origin: Some("src/format.rs".to_string()),
fold: false,
annotations: vec![SourceAnnotation {
label: "error here".to_string(),
annotation_type: AnnotationType::Error,
range: (21, 22),
}],
},
],
opt: FormatOptions {
color: false,
anonymized_line_numbers: false,
},
};
let dl = DisplayList::from(snippet);
println!("{}", dl.to_string());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment