use std::collections::HashMap; use lib::{Lint, LINTS}; use rnix::SyntaxKind; pub fn lint_map_of( lints: &[&'static Box], ) -> HashMap>> { let mut map = HashMap::new(); for lint in lints.iter() { let lint = *lint; let matches = lint.match_kind(); for m in matches { map.entry(m) .and_modify(|v: &mut Vec<_>| v.push(lint)) .or_insert_with(|| vec![lint]); } } map } pub fn lint_map() -> HashMap>> { lint_map_of(&*LINTS) } pub fn get_version_info() -> Option { use std::process::Command; let program = Command::new("nix") .arg("--version") .output() .expect("failed to execute"); std::str::from_utf8(&program.stdout) .ok()? .split(' ') .nth(2) .map(ToOwned::to_owned) }