Skip to main content

vyre_libs/rule/
pattern_exists.rs

1use crate::rule::condition_op;
2use vyre_foundation::ir::{Expr, Program};
3use vyre_spec::OperationContract;
4
5impl PatternExists {
6    /// Build the canonical IR program.
7    ///
8    /// # Examples
9    ///
10    /// ```
11    /// use vyre_libs::rule::pattern_exists::PatternExists;
12    ///
13    /// assert!(!PatternExists::program().entry().is_empty());
14    /// ```
15    #[must_use]
16    pub fn program() -> Program {
17        condition_op::condition_program(OP_ID, || {
18            Expr::ne(condition_op::pattern_state(), Expr::u32(0))
19        })
20    }
21}
22
23/// Stable operation id for pattern existence checks.
24pub const OP_ID: &str = "vyre-libs::rule::pattern_exists";
25
26/// Execution contract annotation for the standard catalog.
27pub const CONTRACT: OperationContract = crate::contracts::RULE_PREDICATE_CHEAP;
28
29/// Pattern existence condition operation.
30#[derive(Debug, Clone, Copy, Default)]
31pub struct PatternExists;