Skip to content

Commit 10129db

Browse files
committed
Change iter_for_region_and_commodity to also return associated ProcessFlows
1 parent bd03672 commit 10129db

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

src/asset.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,15 @@ impl AssetPool {
264264
self.iter().filter(|asset| asset.region_id == *region_id)
265265
}
266266

267-
/// Iterate over only the active assets in a given region that produce or consume a given
268-
/// commodity
267+
/// Iterate over the active assets in a given region that produce/consume a commodity with the
268+
/// associated process flow
269269
pub fn iter_for_region_and_commodity<'a>(
270270
&'a self,
271271
region_id: &'a RegionID,
272272
commodity_id: &'a CommodityID,
273-
) -> impl Iterator<Item = &'a AssetRef> {
274-
self.iter_for_region(region_id).filter(|asset| {
275-
asset.process.contains_commodity_flow(
276-
commodity_id,
277-
&asset.region_id,
278-
asset.commission_year,
279-
)
280-
})
273+
) -> impl Iterator<Item = (&'a AssetRef, &'a ProcessFlow)> {
274+
self.iter_for_region(region_id)
275+
.filter_map(|asset| Some((asset, asset.get_flow(commodity_id)?)))
281276
}
282277

283278
/// Replace the active pool with new and/or already commissioned assets

0 commit comments

Comments
 (0)