pumpkin_core/engine/termination/
combinator.rs

1use super::TerminationCondition;
2
3/// A [`TerminationCondition`] which triggers when one of two given [`TerminationCondition`]s
4/// triggers.
5#[derive(Clone, Copy, Debug)]
6pub struct Combinator<T1, T2> {
7    t1: T1,
8    t2: T2,
9}
10
11impl<T1, T2> Combinator<T1, T2> {
12    /// Combine two [`TerminationCondition`]s into one.
13    pub fn new(t1: T1, t2: T2) -> Self {
14        Combinator { t1, t2 }
15    }
16}
17
18impl<T1: TerminationCondition, T2: TerminationCondition> TerminationCondition
19    for Combinator<T1, T2>
20{
21    fn should_stop(&mut self) -> bool {
22        self.t1.should_stop() || self.t2.should_stop()
23    }
24}