]> git.lizzy.rs Git - rust.git/blob - src/librustc_errors/registry.rs
771542cb06fa6808ea450bbe803947638f0c06dc
[rust.git] / src / librustc_errors / registry.rs
1 use rustc_data_structures::fx::FxHashMap;
2
3 #[derive(Clone)]
4 pub struct Registry {
5     descriptions: FxHashMap<&'static str, &'static str>,
6 }
7
8 impl Registry {
9     pub fn new(descriptions: &[(&'static str, &'static str)]) -> Registry {
10         Registry { descriptions: descriptions.iter().cloned().collect() }
11     }
12
13     pub fn find_description(&self, code: &str) -> Option<&'static str> {
14         self.descriptions.get(code).cloned()
15     }
16 }