aboutsummaryrefslogtreecommitdiff
path: root/bin/src/explain.rs
blob: 6aefa7eba7a7bd61010f853bfd49f6b53cf25311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::err::ExplainErr;

use lib::LINTS;

pub fn explain(code: u32) -> Result<&'static str, ExplainErr> {
    match code {
        0 => Ok("syntax error"),
        _ => LINTS
            .values()
            .flatten()
            .find(|l| l.code() == code)
            .map(|l| l.explanation())
            .ok_or(ExplainErr::LintNotFound(code)),
    }
}