ReportFooter

Struct ReportFooter 

Source
pub struct ReportFooter {
    pub message: String,
    pub notes: Vec<String>,
    pub summary: bool,
}

Fieldsยง

ยงmessage: Stringยงnotes: Vec<String>ยงsummary: bool

Implementationsยง

Sourceยง

impl ReportFooter

A footer for a report.

A footer is a message that is displayed at the end of a report.

Source

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
Hide additional 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}
Source

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
Hide additional 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}
Source

pub fn with_summary(self, enabled: bool) -> Self

Defines if either the summary should be enabled or disabled

Trait Implementationsยง

Sourceยง

impl Clone for ReportFooter

Sourceยง

fn clone(&self) -> ReportFooter

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for ReportFooter

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl<'de> Deserialize<'de> for ReportFooter

Sourceยง

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Sourceยง

impl JsonSchema for ReportFooter

Sourceยง

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Sourceยง

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

Generates a JSON Schema for this type. Read more
Sourceยง

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Sourceยง

impl PartialEq for ReportFooter

Sourceยง

fn eq(&self, other: &ReportFooter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl Serialize for ReportFooter

Sourceยง

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Sourceยง

impl Eq for ReportFooter

Sourceยง

impl StructuralPartialEq for ReportFooter

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> DynClone for T
where T: Clone,

Sourceยง

fn __clone_box(&self, _: Private) -> *mut ()

Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,