Refactor to use Iterator::fold()
This commit is contained in:
parent
30ef3bf0d3
commit
7ecaad830c
1 changed files with 22 additions and 23 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue