Fix old Rust woes

This commit is contained in:
Dorota Czaplejewicz
2019-12-08 18:39:02 +00:00
parent 01a8afad0d
commit 733cbe94ee

View File

@ -227,27 +227,27 @@ pub fn show(
) )
.and_then(|lang| resources::get_layout_names(lang.as_str())); .and_then(|lang| resources::get_layout_names(lang.as_str()));
let use_codes: Box<dyn FnMut(&str) -> Translation>
= Box::new(|name| Translation(name));
let translated_names = all_layouts.iter() let translated_names = all_layouts.iter()
.map(LayoutId::get_name) .map(LayoutId::get_name);
// use a different closure depending on whether we have translations let translated_names: Vec<Translation> = match translations {
.map(match translations { Some(translations) => {
Some(translations) => { translated_names
let use_translations: Box<dyn FnMut(&str) -> Translation> .map(move |name| {
= Box::new(move |name| { translations.get(name)
translations.get(name) .map(|translation| translation.clone())
.map(|translation| translation.clone()) .unwrap_or(Translation(name))
.unwrap_or(Translation(name)) })
}); .collect()
use_translations },
}, None => {
None => use_codes, translated_names.map(|name| Translation(name))
}); .collect()
},
};
// sorted collection of human and machine names // sorted collection of human and machine names
let mut human_names: Vec<(Translation, LayoutId)> = translated_names let mut human_names: Vec<(Translation, LayoutId)> = translated_names
.into_iter()
.zip(all_layouts.clone().into_iter()) .zip(all_layouts.clone().into_iter())
.collect(); .collect();