59. Heterogeneous operator traits (Add/Sub/Mul/Div/Rem with Rhs and Out) (2026-11-21)
- Operator traits accept an optional
Rhstype argument (defaulting toSelf) and an optionaltype Out = Tassociated type (defaulting to the method's return type orSelf). For example,impl Mul<F64> for Vec: fn mul(a, k) = Vec(a.x * k, a.y * k)andimpl Mul<Vec> for Mat2: type Out = Vec; fn mul(lhs, rhs) -> Out = ...coexist on the same struct alongside homogeneousimpl Mul for Mat2without colliding incpl-check(keyed bytrait_impl_key) orcpl-ir(dispatched by(method, rhs_ty)inStructInfo.op_methods). Reason: eliminates.scale(k)/.div(k)workarounds instd.geometry(research/frictions/cf2138f.md),std.mod, andstd.matrixwith one general mechanism available to all user and stdlib structs, while keeping every existingimpl Add/Sub/Mul/Div for Tunchanged. Reverse: reverttrait_impl_key/Def::Impl.trait_args/out_tyincpl-checkandStructInfo.op_methods/struct_op_fn_forincpl-ir.