From a0ad2c484dabc609bf1848b4d2d3d93f5210141d Mon Sep 17 00:00:00 2001 From: Lukasz Anforowicz Date: Fri, 21 Feb 2025 15:27:55 -0800 Subject: [PATCH] Add `specs()` accessor to the `PlatformEval` type. (#423) This helps `guppy` clients which don't want to `eval` the condition, and instead want to decompose and analyze the condition. An example of one such client can be found in: * https://crrev.com/c/6259145/9/tools/crates/gnrt/lib/deps.rs#406 * https://crrev.com/c/6259145/9/tools/crates/gnrt/lib/gn.rs#513 --- guppy/src/platform/platform_eval.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guppy/src/platform/platform_eval.rs b/guppy/src/platform/platform_eval.rs index da48f6ce3ae..d8967cbe0f8 100644 --- a/guppy/src/platform/platform_eval.rs +++ b/guppy/src/platform/platform_eval.rs @@ -159,7 +159,7 @@ pub struct PlatformEval<'g> { assert_covariant!(PlatformEval); -impl PlatformEval<'_> { +impl<'g> PlatformEval<'g> { /// Runs this evaluator against the given platform. pub fn eval(&self, platform: &Platform) -> EnabledTernary { let mut res = EnabledTernary::Disabled; @@ -173,6 +173,11 @@ impl PlatformEval<'_> { } res } + + /// Returns the target specs. + pub fn specs<'a>(&'a self) -> impl Iterator + 'a { + self.specs.iter() + } } #[derive(Clone, Debug)]