pub struct CastFusionRule { /* private fields */ }Expand description
Cast(src→dst) → Op(dst) ≡ Op(src) when the consumer has a
kernel for src.
Only fires when the cast has exactly one consumer (MVP: avoids the DAG complication of partial fan-out elimination). Multi- consumer Cast handling is a follow-up: rewrite one consumer and keep the cast alive for the others.
Implementations§
Source§impl CastFusionRule
impl CastFusionRule
Sourcepub fn new(capabilities: CapabilityPredicate) -> Self
pub fn new(capabilities: CapabilityPredicate) -> Self
Build the rule with a capability predicate. The predicate closes over whatever capability source the caller has (a binding table, a route picker, a static manifest). The rule itself stays decoupled from those internals.
Trait Implementations§
Source§impl Rule for CastFusionRule
impl Rule for CastFusionRule
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable, human-readable name. Shows up in panic messages and
debug traces.
Source§fn family(&self) -> RuleFamily
fn family(&self) -> RuleFamily
Which family this rule belongs to. Determines pass ordering.
Source§fn matches(&self, graph: &Graph, id: NodeId) -> bool
fn matches(&self, graph: &Graph, id: NodeId) -> bool
Whether this rule can rewrite the node at
id. Should be
pure — same inputs, same answer. Called once per node per
pass; the first matching rule wins.Source§fn rewrite(
&self,
graph: &mut Graph,
id: NodeId,
remap: &mut HashMap<NodeId, NodeId>,
)
fn rewrite( &self, graph: &mut Graph, id: NodeId, remap: &mut HashMap<NodeId, NodeId>, )
Apply the rewrite: append fresh nodes to the graph, declare
any side-effect roots if the rewrite emits side-effecting
ops, and write
remap.insert(id, replacement_id) so the
driver can redirect consumer edges. Calling this method
implies matches returned true for the
same (graph, id) — rewriters can rely on the structure
the matcher checked for.Auto Trait Implementations§
impl !RefUnwindSafe for CastFusionRule
impl !UnwindSafe for CastFusionRule
impl Freeze for CastFusionRule
impl Send for CastFusionRule
impl Sync for CastFusionRule
impl Unpin for CastFusionRule
impl UnsafeUnpin for CastFusionRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more