macro_rules! impl_op3 {
($s:ident, $name:expr, $(($t1:ident, $t2:ident, $t3:ident) -> $rt:ident { $f:expr }),*) => { ... };
}
Expand description
Defines a macro for implementing a ternary operation trait.
This macro, when invoked, generates an implementation of the Op3
trait for a given structure.
The trait includes two functions: cost
, which returns a constant cost value associated with the operation, and try_eval
, which attempts to evaluate the operation based on three input values.
The try_eval
function utilizes Rust’s pattern matching to handle specific combinations of value types, applying a provided function using itertools::izip
to iterate over the input values in tandem, mapping them to a result that is collected using galloc_scollect
.
If the provided input types do not match any of the specified patterns, the function returns a false success flag and a Null
value, indicating an unsuccessful evaluation.
This macro simplifies the creation of complex operations by automating the repetitive parts of defining the Op3
implementations.