Trait puffin::algebra::dynamic_function::DynamicFunction
source · pub trait DynamicFunction<PT: ProtocolTypes>:
Fn(&Vec<Box<dyn EvaluatedTerm<PT>>>) -> Result<Box<dyn EvaluatedTerm<PT>>, FnError>
+ Send
+ Sync {
// Required method
fn clone_box(&self) -> Box<dyn DynamicFunction<PT>>;
}
Expand description
Cloneable type for dynamic functions. This trait is automatically implemented for arbitrary
closures and functions of the form: Fn(&Vec<Box<dyn Any>>) -> Box<dyn Any>
Clone
is implemented for Box<dyn DynamicFunction>
using this trick:
https://users.rust-lang.org/t/how-to-clone-a-boxed-closure/31035/25
We want to use Any here and not VariableData (which implements Clone). Else all returned types in functions op_impl.rs would need to return a cloneable struct. Message for example is not.