aboutsummaryrefslogtreecommitdiff
path: root/bin/src/explain.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/src/explain.rs')
-rw-r--r--bin/src/explain.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/src/explain.rs b/bin/src/explain.rs
new file mode 100644
index 0000000..6aefa7e
--- /dev/null
+++ b/bin/src/explain.rs
@@ -0,0 +1,15 @@
1use crate::err::ExplainErr;
2
3use lib::LINTS;
4
5pub fn explain(code: u32) -> Result<&'static str, ExplainErr> {
6 match code {
7 0 => Ok("syntax error"),
8 _ => LINTS
9 .values()
10 .flatten()
11 .find(|l| l.code() == code)
12 .map(|l| l.explanation())
13 .ok_or(ExplainErr::LintNotFound(code)),
14 }
15}