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