use { crate::{ CritMatcherIds, FixedRootMatcher, crit_graph::{ CritFixedRootCriterion, CritFixedRootCriterionBase, CritMgr, CritRoot, CritRootFixed, CritTarget, }, }, linearize::static_map, std::{marker::PhantomData, rc::Rc}, }; pub struct CritMatchConstant(pub bool, pub PhantomData); impl CritMatchConstant where Target: CritTarget, { pub fn create( roots: &Rc, ids: &CritMatcherIds, ) -> FixedRootMatcher> { static_map! { v => CritRoot::new( roots, ids.next(), CritRootFixed(Self(v, PhantomData), PhantomData), ), } } } impl CritFixedRootCriterionBase for CritMatchConstant where Target: CritTarget, { fn constant(&self) -> bool { self.0 } fn not<'a>(&self, mgr: &'a Target::Mgr) -> &'a FixedRootMatcher where Self: CritFixedRootCriterion, { mgr.match_constant() } } impl CritFixedRootCriterion for CritMatchConstant where Target: CritTarget, { const COMPARE: bool = false; fn matches(&self, _data: &Target) -> bool { self.0 } }