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///
13/// Combined 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///
18/// Built by `SolverFactoryBuilder::with_phase()` which wraps `(self.phases, phase)`.
19impl<S, D, BestCb, Prev, P> Phase<S, D, BestCb> for (Prev, P)
20where
21    S: PlanningSolution,
22    D: Director<S>,
23    BestCb: BestSolutionCallback<S>,
24    Prev: Phase<S, D, BestCb>,
25    P: Phase<S, D, BestCb>,
26{
27    fn solve(&mut self, solver_scope: &mut SolverScope<'_, S, D, BestCb>) {
28        self.0.solve(solver_scope);
29        self.1.solve(solver_scope);
30    }
31
32    fn phase_type_name(&self) -> &'static str {
33        "PhaseTuple"
34    }
35}