garando_errors 0.1.0

Backport of librustc_errors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::collections::HashMap;

#[derive(Clone)]
pub struct Registry {
    descriptions: HashMap<&'static str, &'static str>,
}

impl Registry {
    pub fn new(descriptions: &[(&'static str, &'static str)]) -> Registry {
        Registry {
            descriptions: descriptions.iter().cloned().collect(),
        }
    }

    pub fn find_description(&self, code: &str) -> Option<&'static str> {
        self.descriptions.get(code).cloned()
    }
}