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