Refactor to use Iterator::fold()

This commit is contained in:
Matthias Beyer 2018-01-28 21:05:05 +01:00
parent 30ef3bf0d3
commit 7ecaad830c

View file

@ -634,12 +634,11 @@ pub mod store_check {
// //
// The lambda returns an error if something fails // The lambda returns an error if something fails
let aggregate_link_network = |store: &Store| -> Result<HashMap<StoreId, Linking>> { let aggregate_link_network = |store: &Store| -> Result<HashMap<StoreId, Linking>> {
let iter = store store
.entries()? .entries()?
.into_get_iter(store); .into_get_iter(store)
.fold(Ok(HashMap::new()), |map, element| {
let mut map = HashMap::new(); map.and_then(|mut map| {
for element in iter {
debug!("Checking element = {:?}", element); debug!("Checking element = {:?}", element);
let entry = element?.ok_or_else(|| { let entry = element?.ok_or_else(|| {
LE::from(String::from("TODO: Not yet handled")) LE::from(String::from("TODO: Not yet handled"))
@ -660,9 +659,9 @@ pub mod store_check {
} }
map.insert(entry.get_location().clone(), linking); map.insert(entry.get_location().clone(), linking);
}
Ok(map) Ok(map)
})
})
}; };
// Helper to check whethre all StoreIds in the network actually exists // Helper to check whethre all StoreIds in the network actually exists