pub struct ReportFooter {
pub message: String,
pub notes: Vec<String>,
pub summary: bool,
}Fieldsยง
ยงmessage: Stringยงnotes: Vec<String>ยงsummary: boolImplementationsยง
A footer is a message that is displayed at the end of a report.
Sourcepub fn new<M: Into<String>>(message: M) -> Self
pub fn new<M: Into<String>>(message: M) -> Self
Create a new footer.
Examples found in repository?
examples/simple.rs (line 44)
13fn main() -> Result<(), Error> {
14 let origin = "example.ara";
15 let code = r#"
16$b = match $a {
17 1 => 2,
18 2 => 3,
19 default => "string",
20};
21"#;
22
23 let map = SourceMap::new(vec![Source::new(SourceKind::Script, origin, code)]);
24
25 let report = Report::new()
26 .with_issue(
27 Issue::error("E0417", "`match` arms have incompatible types")
28 .with_source(origin, 6, 67)
29 .with_annotation(
30 Annotation::secondary(origin, 26, 27)
31 .with_message("this is found to be of type `{int}`"),
32 )
33 .with_annotation(
34 Annotation::secondary(origin, 38, 39)
35 .with_message("this is found to be of type `{int}`"),
36 )
37 .with_annotation(
38 Annotation::secondary(origin, 56, 64)
39 .with_message("expected `{int}`, found `{string}`"),
40 )
41 .with_note("for more information about this error, try `ara --explain E0417`"),
42 )
43 .with_footer(
44 ReportFooter::new("this is a report footer message")
45 .with_note("this is a note message"),
46 );
47
48 let builder = ReportBuilder::new(&map)
49 .with_colors(ColorChoice::Always)
50 .with_charset(CharSet::Unicode);
51
52 builder.print(&report)
53}More examples
examples/collection.rs (line 53)
14fn main() -> Result<(), Error> {
15 let first_origin = "example.ara";
16 let first_code = r#"
17$b = match $a {
18 1 => 2,
19 2 => 3,
20 default => "string",
21};
22"#;
23
24 let second_origin = "example-2.ara";
25 let second_code = r#"
26function foo(Bar&float) {}
27"#;
28
29 let map = SourceMap::new(vec![
30 Source::new(SourceKind::Script, first_origin, first_code),
31 Source::new(SourceKind::Script, second_origin, second_code),
32 ]);
33
34 let first_report = Report::new()
35 .with_issue(
36 Issue::error("E0417", "`match` arms have incompatible types")
37 .with_source(first_origin, 6, 67)
38 .with_annotation(
39 Annotation::secondary(first_origin, 26, 27)
40 .with_message("this is found to be of type `{int}`"),
41 )
42 .with_annotation(
43 Annotation::secondary(first_origin, 38, 39)
44 .with_message("this is found to be of type `{int}`"),
45 )
46 .with_annotation(
47 Annotation::secondary(first_origin, 56, 64)
48 .with_message("expected `{int}`, found `{string}`"),
49 )
50 .with_note("for more information about this error, try `ara --explain E0417`"),
51 )
52 .with_footer(
53 ReportFooter::new("this is a report footer message")
54 .with_note("this is a note message"),
55 );
56
57 let second_report = Report::new()
58 .with_issue(
59 Issue::error(
60 "P0015",
61 "scalar type `float` cannot be used in an intersection",
62 )
63 .with_source(second_origin, 18, 23)
64 .with_annotation(
65 Annotation::secondary(second_origin, 17, 19)
66 .with_message("scalar type `float` cannot be used in an intersection"),
67 )
68 .with_note("a scalar type is either `int`, `float`, `string`, or `bool`.")
69 .with_note("try using a different type for the intersection."),
70 )
71 .with_issue(Issue::bug("B0001", "failed to read the file"))
72 .with_footer(
73 ReportFooter::new("this is a report footer message")
74 .with_note("this is a note message"),
75 );
76
77 let reports: ReportCollection = vec![&first_report, &second_report];
78
79 let builder = ReportBuilder::new(&map)
80 .with_colors(ColorChoice::Always)
81 .with_charset(CharSet::Unicode);
82
83 builder.print(&reports)
84}examples/example.rs (line 100)
14fn main() -> Result<(), Error> {
15 let map = SourceMap::new(vec![Source::inline(
16 SourceKind::Script,
17 r#"
18function main(): int|string {
19 $a = 1;
20 $b = 2;
21
22 $c = $a + $b;
23
24 $b = match ($a) {
25 1 => 2,
26 2 => 3,
27 default => "string",
28 };
29
30 return $c + $b;
31}
32"#,
33 )]);
34
35 let report = Report::new()
36 .with_issue(
37 Issue::error("E123", "some error here")
38 .with_source(DEFAULT_NAME, 35, 41)
39 .with_annotation(
40 Annotation::secondary(DEFAULT_NAME, 41, 42).with_message("an annotation"),
41 )
42 .with_note("this is a note"),
43 )
44 .with_issue(
45 Issue::warning("W123", "some warning here")
46 .with_source(DEFAULT_NAME, 29, 187)
47 .with_annotation(
48 Annotation::secondary(DEFAULT_NAME, 126, 127).with_message("an annotation"),
49 )
50 .with_note("this is a note"),
51 )
52 .with_issue(
53 Issue::warning("W124", "some warning here")
54 .with_source(DEFAULT_NAME, 29, 187)
55 .with_annotation(
56 Annotation::secondary(DEFAULT_NAME, 126, 127).with_message("an annotation"),
57 )
58 .with_note("this is a note"),
59 )
60 .with_issue(
61 Issue::note("N123", "some note here")
62 .with_source(DEFAULT_NAME, 84, 163)
63 .with_annotation(
64 Annotation::secondary(DEFAULT_NAME, 105, 112).with_message("an annotation"),
65 )
66 .with_annotation(
67 Annotation::secondary(DEFAULT_NAME, 121, 128)
68 .with_message("another annotation"),
69 )
70 .with_annotation(
71 Annotation::secondary(DEFAULT_NAME, 137, 147).with_message("and another"),
72 )
73 .with_note("this is a note"),
74 )
75 .with_issue(
76 Issue::help("H123", "some help here")
77 .with_source(DEFAULT_NAME, 137, 147)
78 .with_annotation(
79 Annotation::secondary(DEFAULT_NAME, 35, 42).with_message("an annotation"),
80 )
81 .with_note("this is a note"),
82 )
83 .with_issue(
84 Issue::bug("E123", "`match` arms have incompatible types")
85 .with_source(DEFAULT_NAME, 84, 163)
86 .with_annotation(
87 Annotation::secondary(DEFAULT_NAME, 110, 111)
88 .with_message("this is found to be of type `{int}`"),
89 )
90 .with_annotation(
91 Annotation::secondary(DEFAULT_NAME, 126, 127)
92 .with_message("this is found to be of type `{int}`"),
93 )
94 .with_annotation(
95 Annotation::secondary(DEFAULT_NAME, 148, 156)
96 .with_message("expected `{int}`, found `{string}`"),
97 )
98 .with_note("for more information about this error, try `ara --explain E0308`"),
99 )
100 .with_footer(ReportFooter::new("this is a report footer message"));
101
102 let builder = ReportBuilder::new(&map)
103 .with_colors(ColorChoice::Always)
104 .with_charset(CharSet::Unicode);
105
106 builder.print(&report)
107}Sourcepub fn with_note<S: Into<String>>(self, note: S) -> Self
pub fn with_note<S: Into<String>>(self, note: S) -> Self
Add a note to this footer.
Examples found in repository?
examples/simple.rs (line 45)
13fn main() -> Result<(), Error> {
14 let origin = "example.ara";
15 let code = r#"
16$b = match $a {
17 1 => 2,
18 2 => 3,
19 default => "string",
20};
21"#;
22
23 let map = SourceMap::new(vec![Source::new(SourceKind::Script, origin, code)]);
24
25 let report = Report::new()
26 .with_issue(
27 Issue::error("E0417", "`match` arms have incompatible types")
28 .with_source(origin, 6, 67)
29 .with_annotation(
30 Annotation::secondary(origin, 26, 27)
31 .with_message("this is found to be of type `{int}`"),
32 )
33 .with_annotation(
34 Annotation::secondary(origin, 38, 39)
35 .with_message("this is found to be of type `{int}`"),
36 )
37 .with_annotation(
38 Annotation::secondary(origin, 56, 64)
39 .with_message("expected `{int}`, found `{string}`"),
40 )
41 .with_note("for more information about this error, try `ara --explain E0417`"),
42 )
43 .with_footer(
44 ReportFooter::new("this is a report footer message")
45 .with_note("this is a note message"),
46 );
47
48 let builder = ReportBuilder::new(&map)
49 .with_colors(ColorChoice::Always)
50 .with_charset(CharSet::Unicode);
51
52 builder.print(&report)
53}More examples
examples/collection.rs (line 54)
14fn main() -> Result<(), Error> {
15 let first_origin = "example.ara";
16 let first_code = r#"
17$b = match $a {
18 1 => 2,
19 2 => 3,
20 default => "string",
21};
22"#;
23
24 let second_origin = "example-2.ara";
25 let second_code = r#"
26function foo(Bar&float) {}
27"#;
28
29 let map = SourceMap::new(vec![
30 Source::new(SourceKind::Script, first_origin, first_code),
31 Source::new(SourceKind::Script, second_origin, second_code),
32 ]);
33
34 let first_report = Report::new()
35 .with_issue(
36 Issue::error("E0417", "`match` arms have incompatible types")
37 .with_source(first_origin, 6, 67)
38 .with_annotation(
39 Annotation::secondary(first_origin, 26, 27)
40 .with_message("this is found to be of type `{int}`"),
41 )
42 .with_annotation(
43 Annotation::secondary(first_origin, 38, 39)
44 .with_message("this is found to be of type `{int}`"),
45 )
46 .with_annotation(
47 Annotation::secondary(first_origin, 56, 64)
48 .with_message("expected `{int}`, found `{string}`"),
49 )
50 .with_note("for more information about this error, try `ara --explain E0417`"),
51 )
52 .with_footer(
53 ReportFooter::new("this is a report footer message")
54 .with_note("this is a note message"),
55 );
56
57 let second_report = Report::new()
58 .with_issue(
59 Issue::error(
60 "P0015",
61 "scalar type `float` cannot be used in an intersection",
62 )
63 .with_source(second_origin, 18, 23)
64 .with_annotation(
65 Annotation::secondary(second_origin, 17, 19)
66 .with_message("scalar type `float` cannot be used in an intersection"),
67 )
68 .with_note("a scalar type is either `int`, `float`, `string`, or `bool`.")
69 .with_note("try using a different type for the intersection."),
70 )
71 .with_issue(Issue::bug("B0001", "failed to read the file"))
72 .with_footer(
73 ReportFooter::new("this is a report footer message")
74 .with_note("this is a note message"),
75 );
76
77 let reports: ReportCollection = vec![&first_report, &second_report];
78
79 let builder = ReportBuilder::new(&map)
80 .with_colors(ColorChoice::Always)
81 .with_charset(CharSet::Unicode);
82
83 builder.print(&reports)
84}Sourcepub fn with_summary(self, enabled: bool) -> Self
pub fn with_summary(self, enabled: bool) -> Self
Defines if either the summary should be enabled or disabled
Trait Implementationsยง
Sourceยงfn clone(&self) -> ReportFooter
fn clone(&self) -> ReportFooter
Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSourceยงfn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Sourceยงfn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Sourceยงfn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Sourceยงfn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Sourceยงfn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementationsยง
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more