stern4rust/reporting/rule_explanation.rs
1// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
2// Licensed under the MIT License
3// SPDX-License-Identifier: MIT
4
5// What one rule wants, said in the rule's own words: a sentence, a scrap of
6// source that breaks it, and the same scrap put right.
7//
8// The rule answers for itself, the way it already answers `requirement`. The
9// alternative -- a table in the printer mapping name to prose -- is a second
10// idea of which rules exist, kept in step by hand, and it would fall out of
11// date the first time a rule changed its mind without the table being told.
12//
13// `breaks` and `instead` are source rather than description because the
14// question a reader arrives with is "what does this look like", and a sentence
15// answering it is longer and less exact than two lines of Rust.
16pub struct RuleExplanation {
17 pub name: &'static str,
18 pub summary: &'static str,
19 pub breaks: &'static str,
20 pub instead: &'static str,
21}
22
23impl RuleExplanation {
24 pub fn new(
25 name: &'static str,
26 summary: &'static str,
27 breaks: &'static str,
28 instead: &'static str,
29 ) -> Self {
30 Self {
31 name,
32 summary,
33 breaks,
34 instead,
35 }
36 }
37}