Skip to main content

solverforge_solver/phase/
tuple_impl.rs

1//! Blanket Phase implementation for nested tuples.
2
3use solverforge_core::domain::PlanningSolution;
4use solverforge_scoring::ScoreDirector;
5
6use crate::scope::SolverScope;
7
8use super::Phase;
9
10/// Blanket impl: any `(Prev, P)` where both implement `Phase` is itself a `Phase`.
11///
12/// Combined with the `()` no-op impl, this covers all nested tuple arities:
13/// - `((), P1)` — single phase
14/// - `(((), P1), P2)` — two phases
15/// - `((((), P1), P2), P3)` — three phases, etc.
16///
17/// Built by `SolverFactoryBuilder::with_phase()` which wraps `(self.phases, phase)`.
18impl<S, D, Prev, P> Phase<S, D> for (Prev, P)
19where
20    S: PlanningSolution,
21    D: ScoreDirector<S>,
22    Prev: Phase<S, D>,
23    P: Phase<S, D>,
24{
25    fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D>) {
26        self.0.solve(solver_scope);
27        self.1.solve(solver_scope);
28    }
29
30    fn phase_type_name(&self) -> &'static str {
31        "PhaseTuple"
32    }
33}