macro_rules! impl_op1 {
($s:ident, $name:expr, $($t1:ident -> $rt:ident { $f:expr }),*) => { ... };
}
Expand description
Implements a macro to define unary operations for expression types.
This macro provides a structured way to implement the Op1
trait for a given type, enabling the definition of operation costs and evaluation methods.
Specifically, it defines the cost
method to return a constant value associated with the operation type and the try_eval
method to attempt evaluation of the operation on an input value.
Within the implementation, the evaluation is performed by matching on the input value type.
For each specified type conversion, it maps an expression over the input’s iterable values, collecting results using galloc_scollect
.
If the input type matches one of the specified conversions, the operation applies and returns true
along with the resulting value; otherwise, it returns false
and a Null
value.
This macro thus facilitates efficient and reusable implementations of unary operations over various value types in the string synthesis framework.