macro_rules! create_unit_operations {
($lhs_struct:ident * $rhs_struct:ident => $result_struct:ident) => { ... };
($lhs_struct:ident / $rhs_struct:ident => $result_struct:ident) => { ... };
}Expand description
This macro generates multiplication and division operations between two different unit structures, resulting in a third unit structure.
§Parameters
$lhs_struct: The left-hand side unit structure for the operation.$rhs_struct: The right-hand side unit structure for the operation.$result_struct: The resulting unit structure from the operation.
§Generated Implementations
std::ops::Mul<$rhs_struct>: Multiplies an instance of the left-hand side struct by an instance of the right-hand side struct, resulting in an instance of the result struct.std::ops::Div<$rhs_struct>: Divides an instance of the left-hand side struct by an instance of the right-hand side struct, resulting in an instance of the result struct.
§Example
struct Length(f64);
struct Time(f64);
struct Speed(f64);
create_unit_operations!(Length / Time => Speed);
let length = Length(100.0);
let time = Time(10.0);
let speed = length / time; // Speed(10.0)
§Note
This macro is intended to be used in conjunction with the create_unit macro to define unit operations between different unit structures.