Skip to content

Commit c66d784

Browse files
authored
Merge pull request #32 from botika/master
Fix no copy when cast `Snippet` to `DisplayList` and #29
2 parents 40cec7a + d10d37a commit c66d784

24 files changed

+589
-341
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ yansi-term = { version = "0.1", optional = true }
2020

2121
[dev-dependencies]
2222
glob = "0.3"
23-
serde_yaml = "0.8"
23+
toml = "0.5"
2424
serde = { version = "1.0", features = ["derive"] }
2525
difference = "2.0"
2626
yansi-term = "0.1"

benches/simple.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,26 @@ fn create_snippet() {
3333
}
3434
_ => continue,
3535
}
36-
}"#
37-
.to_string(),
36+
}"#,
3837
line_start: 51,
39-
origin: Some("src/format.rs".to_string()),
38+
origin: Some("src/format.rs"),
4039
fold: false,
4140
annotations: vec![
4241
SourceAnnotation {
43-
label: "expected `Option<String>` because of return type".to_string(),
42+
label: "expected `Option<String>` because of return type",
4443
annotation_type: AnnotationType::Warning,
4544
range: (5, 19),
4645
},
4746
SourceAnnotation {
48-
label: "expected enum `std::option::Option`".to_string(),
47+
label: "expected enum `std::option::Option`",
4948
annotation_type: AnnotationType::Error,
5049
range: (26, 724),
5150
},
5251
],
5352
}],
5453
title: Some(Annotation {
55-
label: Some("mismatched types".to_string()),
56-
id: Some("E0308".to_string()),
54+
label: Some("mismatched types"),
55+
id: Some("E0308"),
5756
annotation_type: AnnotationType::Error,
5857
}),
5958
footer: vec![],

examples/expected_type.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@ use annotate_snippets::{
66
fn main() {
77
let snippet = Snippet {
88
title: Some(Annotation {
9-
label: Some("expected type, found `22`".to_string()),
9+
label: Some("expected type, found `22`"),
1010
id: None,
1111
annotation_type: AnnotationType::Error,
1212
}),
1313
footer: vec![],
1414
slices: vec![Slice {
1515
source: r#" annotations: vec![SourceAnnotation {
1616
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
17-
.to_string(),
18-
range: <22, 25>,"#
19-
.to_string(),
17+
,
18+
range: <22, 25>,"#,
2019
line_start: 26,
21-
origin: Some("examples/footer.rs".to_string()),
20+
origin: Some("examples/footer.rs"),
2221
fold: true,
2322
annotations: vec![
2423
SourceAnnotation {
25-
label: "".to_string(),
24+
label: "",
2625
annotation_type: AnnotationType::Error,
2726
range: (205, 207),
2827
},
2928
SourceAnnotation {
30-
label: "while parsing this struct".to_string(),
29+
label: "while parsing this struct",
3130
annotation_type: AnnotationType::Info,
3231
range: (34, 50),
3332
},

examples/footer.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@ use annotate_snippets::{
66
fn main() {
77
let snippet = Snippet {
88
title: Some(Annotation {
9-
label: Some("mismatched types".to_string()),
10-
id: Some("E0308".to_string()),
9+
label: Some("mismatched types"),
10+
id: Some("E0308"),
1111
annotation_type: AnnotationType::Error,
1212
}),
1313
footer: vec![Annotation {
1414
label: Some(
15-
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`"
16-
.to_string(),
15+
"expected type: `snippet::Annotation`\n found type: `__&__snippet::Annotation`",
1716
),
1817
id: None,
1918
annotation_type: AnnotationType::Note,
2019
}],
2120
slices: vec![Slice {
22-
source: " slices: vec![\"A\",".to_string(),
21+
source: " slices: vec![\"A\",",
2322
line_start: 13,
24-
origin: Some("src/multislice.rs".to_string()),
23+
origin: Some("src/multislice.rs"),
2524
fold: false,
2625
annotations: vec![SourceAnnotation {
27-
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
28-
.to_string(),
26+
label: "expected struct `annotate_snippets::snippet::Slice`, found reference",
2927
range: (21, 24),
3028
annotation_type: AnnotationType::Error,
3129
}],

examples/format.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,26 @@ fn main() {
2727
}
2828
_ => continue,
2929
}
30-
}"#
31-
.to_string(),
30+
}"#,
3231
line_start: 51,
33-
origin: Some("src/format.rs".to_string()),
32+
origin: Some("src/format.rs"),
3433
fold: false,
3534
annotations: vec![
3635
SourceAnnotation {
37-
label: "expected `Option<String>` because of return type".to_string(),
36+
label: "expected `Option<String>` because of return type",
3837
annotation_type: AnnotationType::Warning,
3938
range: (5, 19),
4039
},
4140
SourceAnnotation {
42-
label: "expected enum `std::option::Option`".to_string(),
41+
label: "expected enum `std::option::Option`",
4342
annotation_type: AnnotationType::Error,
4443
range: (26, 724),
4544
},
4645
],
4746
}],
4847
title: Some(Annotation {
49-
label: Some("mismatched types".to_string()),
50-
id: Some("E0308".to_string()),
48+
label: Some("mismatched types"),
49+
id: Some("E0308"),
5150
annotation_type: AnnotationType::Error,
5251
}),
5352
footer: vec![],

examples/multislice.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ use annotate_snippets::{
66
fn main() {
77
let snippet = Snippet {
88
title: Some(Annotation {
9-
label: Some("mismatched types".to_string()),
9+
label: Some("mismatched types"),
1010
id: None,
1111
annotation_type: AnnotationType::Error,
1212
}),
1313
footer: vec![],
1414
slices: vec![
1515
Slice {
16-
source: "Foo".to_string(),
16+
source: "Foo",
1717
line_start: 51,
18-
origin: Some("src/format.rs".to_string()),
18+
origin: Some("src/format.rs"),
1919
fold: false,
2020
annotations: vec![],
2121
},
2222
Slice {
23-
source: "Faa".to_string(),
23+
source: "Faa",
2424
line_start: 129,
25-
origin: Some("src/display.rs".to_string()),
25+
origin: Some("src/display.rs"),
2626
fold: false,
2727
annotations: vec![],
2828
},

0 commit comments

Comments
 (0)