Skip to main content

CostFunction

Trait CostFunction 

Source
pub trait CostFunction<L: Language> {
    type Cost: Ord + Clone + Debug;

    // Required method
    fn cost<C>(&self, enode: &L, costs: C) -> Self::Cost
       where C: Fn(Id) -> Self::Cost;

    // Provided method
    fn cost_rec(&self, expr: &RecExpr<L>) -> Self::Cost { ... }
}
Expand description

A cost function to guide extraction.

If you want to use your e-graph analysis in your cost function, then your cost function should hold a reference to the e-graph.

Required Associated Types§

Required Methods§

Source

fn cost<C>(&self, enode: &L, costs: C) -> Self::Cost
where C: Fn(Id) -> Self::Cost,

Provided Methods§

Source

fn cost_rec(&self, expr: &RecExpr<L>) -> Self::Cost

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§