1 use rustc_data_structures::fx::FxHashMap;
4 pub struct InvalidErrorCode;
8 long_descriptions: FxHashMap<&'static str, Option<&'static str>>,
12 pub fn new(long_descriptions: &[(&'static str, Option<&'static str>)]) -> Registry {
13 Registry { long_descriptions: long_descriptions.iter().copied().collect() }
16 /// Returns `InvalidErrorCode` if the code requested does not exist in the
17 /// registry. Otherwise, returns an `Option` where `None` means the error
18 /// code is valid but has no extended information.
19 pub fn try_find_description(
22 ) -> Result<Option<&'static str>, InvalidErrorCode> {
23 self.long_descriptions.get(code).copied().ok_or(InvalidErrorCode)