num-traits icon indicating copy to clipboard operation
num-traits copied to clipboard

`Float` should imply `MulAdd`, instead of having own `mul_add` method.

Open zakarumych opened this issue 5 years ago • 1 comments

In generic code I would like Float bound to be enough to use it where MulAdd is expected given there is Float::mul_add, so trait can always be implemented. Maybe even put it under NumOps since Mul + Add is enough to implement this trait, with fusion for types that support it and as a * b + c for other types.

zakarumych avatar Mar 16 '21 09:03 zakarumych

Maybe even put it under NumOps since Mul + Add is enough to implement this trait,

This only works if all of the RHS and Output types are the same.

Anyway, it would be a breaking change to require the relatively new MulAdd on the older traits, but you can easily create your own trait NewNum: Sized + NumOps + MulAdd<Output = Self> {}.

cuviper avatar Mar 16 '21 17:03 cuviper