Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions benches/simple.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#![allow(clippy::unit_arg)]
#[macro_use]
extern crate criterion;

use criterion::black_box;
use criterion::Criterion;
use criterion::{black_box, Criterion};

use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

fn create_snippet() {
let snippet = Snippet {
Expand Down Expand Up @@ -46,7 +47,7 @@ fn create_snippet() {
SourceAnnotation {
label: "expected enum `std::option::Option`".to_string(),
annotation_type: AnnotationType::Error,
range: (23, 745),
range: (26, 724),
},
],
}],
Expand All @@ -56,11 +57,14 @@ fn create_snippet() {
annotation_type: AnnotationType::Error,
}),
footer: vec![],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true, false);
let _result = dlf.format(&dl);
let _result = dl.to_string();
}

pub fn criterion_benchmark(c: &mut Criterion) {
Expand Down
16 changes: 10 additions & 6 deletions examples/expected_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

fn main() {
let snippet = Snippet {
Expand All @@ -23,7 +24,7 @@ fn main() {
SourceAnnotation {
label: "".to_string(),
annotation_type: AnnotationType::Error,
range: (208, 210),
range: (205, 207),
},
SourceAnnotation {
label: "while parsing this struct".to_string(),
Expand All @@ -32,9 +33,12 @@ fn main() {
},
],
}],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true, false);
println!("{}", dlf.format(&dl));
println!("{}", dl);
}
14 changes: 9 additions & 5 deletions examples/footer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

fn main() {
let snippet = Snippet {
Expand Down Expand Up @@ -29,9 +30,12 @@ fn main() {
annotation_type: AnnotationType::Error,
}],
}],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true, false);
println!("{}", dlf.format(&dl));
println!("{}", dl);
}
16 changes: 10 additions & 6 deletions examples/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};

fn main() {
let snippet = Snippet {
Expand Down Expand Up @@ -40,7 +41,7 @@ fn main() {
SourceAnnotation {
label: "expected enum `std::option::Option`".to_string(),
annotation_type: AnnotationType::Error,
range: (23, 745),
range: (26, 724),
},
],
}],
Expand All @@ -50,9 +51,12 @@ fn main() {
annotation_type: AnnotationType::Error,
}),
footer: vec![],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true, false);
println!("{}", dlf.format(&dl));
println!("{}", dl);
}
14 changes: 9 additions & 5 deletions examples/multislice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet};
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet},
};

fn main() {
let snippet = Snippet {
Expand All @@ -26,9 +27,12 @@ fn main() {
annotations: vec![],
},
],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true, false);
println!("{}", dlf.format(&dl));
println!("{}", dl);
}
Loading