Pick the best recipe for `ctx`. Walks the `RULES` table top-to-bottom; the first rule whose predicate matches selects its recipe. Falls back to [`Recipe::InPlaceEdit`] when nothing matches. `log::trace!` is emitted for the match (or fallback) so production builds can introspect which rule fired without rebuilding.
(ctx: &RecipeContext<'_>)
| 95 | /// `log::trace!` is emitted for the match (or fallback) so production |
| 96 | /// builds can introspect which rule fired without rebuilding. |
| 97 | pub fn detect_recipe(ctx: &RecipeContext<'_>) -> Recipe { |
| 98 | for rule in RULES { |
| 99 | if (rule.predicate)(ctx) { |
| 100 | log::trace!( |
| 101 | "recipes::detect_recipe: path={:?} matched rule={:?} → {:?}", |
| 102 | ctx.path, |
| 103 | rule.name, |
| 104 | rule.recipe |
| 105 | ); |
| 106 | return rule.recipe; |
| 107 | } |
| 108 | } |
| 109 | log::trace!( |
| 110 | "recipes::detect_recipe: path={:?} no rule matched → InPlaceEdit", |
| 111 | ctx.path |
| 112 | ); |
| 113 | Recipe::InPlaceEdit |
| 114 | } |
| 115 | |
| 116 | #[cfg(test)] |
| 117 | mod tests { |
no outgoing calls