Trait hugr_core::extension::ConstFold

source ·
pub trait ConstFold: Send + Sync {
    // Required method
    fn fold(
        &self,
        type_args: &[TypeArg],
        consts: &[(IncomingPort, Value)],
    ) -> ConstFoldResult;
}
Expand description

Trait implemented by extension operations that can perform constant folding.

Required Methods§

source

fn fold( &self, type_args: &[TypeArg], consts: &[(IncomingPort, Value)], ) -> ConstFoldResult

Given type arguments type_args and crate::ops::Const values for inputs at crate::IncomingPorts, try to evaluate the operation.

Trait Implementations§

source§

impl Debug for Box<dyn ConstFold>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§

source§

impl ConstFold for NaryLogic

source§

impl ConstFold for Folder

source§

impl<T> ConstFold for T
where T: Fn(&[(IncomingPort, Value)]) -> ConstFoldResult + Send + Sync,

Blanket implementation for functions that only require the constants to evaluate - type arguments are not relevant.