Readability

This commit is contained in:
elvis
2025-06-12 20:00:05 +02:00
parent a25316fa20
commit c9e3701460

View File

@ -27,11 +27,19 @@ impl<'a> Iterator for TransitionsIterator<'a> {
type Item = (RSlabel<'a>, RSsystem<'a>); type Item = (RSlabel<'a>, RSsystem<'a>);
fn next(&mut self) -> Option<(RSlabel<'a>, RSsystem<'a>)> { fn next(&mut self) -> Option<(RSlabel<'a>, RSsystem<'a>)> {
let choice = self.choices_iterator.next()?; let (c, k) = self.choices_iterator.next()?;
let t = self.system.get_available_entities().union(choice.0.as_ref()); let t = self.system.get_available_entities().union(c.as_ref());
let (reactants, reactantsi, inihibitors, ireactants, products) let (reactants,
= self.system.get_reaction_rules().iter() reactantsi,
.fold((RSset::new(), RSset::new(), RSset::new(), RSset::new(), RSset::new()), inihibitors,
ireactants,
products) =
self.system.get_reaction_rules().iter()
.fold((RSset::new(), // reactants
RSset::new(), // reactantsi
RSset::new(), // inihibitors
RSset::new(), // ireactants
RSset::new()), // products
|acc, reaction| if reaction.enabled(&t) { |acc, reaction| if reaction.enabled(&t) {
(acc.0.union(reaction.reactants()), (acc.0.union(reaction.reactants()),
acc.1, acc.1,
@ -49,17 +57,19 @@ impl<'a> Iterator for TransitionsIterator<'a> {
); );
let label = RSlabel::from(self.system.get_available_entities().clone(), let label = RSlabel::from(self.system.get_available_entities().clone(),
(*choice.0).clone(), (*c).clone(),
t, t,
reactants, reactants,
reactantsi, reactantsi,
inihibitors, inihibitors,
ireactants, ireactants,
products.clone()); products.clone()
);
let new_system = RSsystem::from(self.system.get_delta().clone(), let new_system = RSsystem::from(self.system.get_delta().clone(),
products, products,
(*choice.1).clone(), (*k).clone(),
self.system.get_reaction_rules().clone()); self.system.get_reaction_rules().clone()
);
Some((label, new_system)) Some((label, new_system))
} }
} }