Macro binary_operation

Source
macro_rules! binary_operation {
    (
        impl $op_trait:ident for ...($TGuarded:ty, $TUnguarded:ty) {
            $doc:literal
            fn $op_method:ident ($lhs:ident : $lhs_internal:ty, $rhs:ident : $rhs_internal:ty) -> $ret:ty
            $implementation:block
        }
    ) => { ... };
    (
        $op_trait:ident :: $op_method:ident
        $doc:literal
        fn ($lhs:ident : $LHS:ty, $rhs:ident : $RHS:ty) -> $ret:ty $implementation:block
    ) => { ... };
}
Expand description

Defines a binary operation for GuardedF64 with the specified trait and method.

This macro generates implementations for various combinations of GuardedF64, f64, and UnguardedF64 types, allowing for flexible arithmetic operations while ensuring that the results are checked for validity.

ยงArguments

  • $op_trait - The trait representing the binary operation (e.g., Add, Sub, etc.).
  • $op_method - The method name for the operation (e.g., add, sub, etc.).
  • $implementation - A block of code that defines how the operation is performed.
  • $doc - A documentation string that describes the operation and its usage.