While I get your proposal, I’d think this would make dealing with float hell. Do you really want to .unwrap() every time you deal with it? Surely not.
One thing that would be great, is that the / operator could work between Result and f64, as well as between Result and Result. Would be like doing a .map(|left| left / right) operation.
Well, not every time. Only if I do a division or get an ieee_754_f64 from the outside world. That doesn’t happen terribly often in the applications I’ve worked on.
And if it does go wrong, I do want it to explode right then and there. Worst case would be, if it writes random NaNs into some database and no one knows where they came from.
As for your suggestion with the slash accepting Results, yeah, that could resolve some pain, but I’ve rarely seen multiple divisions being necessary back-to-back and I don’t want people passing around a Result<f64> in the codebase. Then you can’t see where it went wrong anymore either.
So, personally, I wouldn’t put that division operator into the stdlib, but having it available as a library, if someone needs it, would be cool, yeah.
While I get your proposal, I’d think this would make dealing with float hell. Do you really want to
.unwrap()
every time you deal with it? Surely not.One thing that would be great, is that the
/
operator could work betweenResult
andf64
, as well as betweenResult
andResult
. Would be like doing a.map(|left| left / right)
operation.Well, not every time. Only if I do a division or get an
ieee_754_f64
from the outside world. That doesn’t happen terribly often in the applications I’ve worked on.And if it does go wrong, I do want it to explode right then and there. Worst case would be, if it writes random
NaN
s into some database and no one knows where they came from.As for your suggestion with the slash accepting
Result
s, yeah, that could resolve some pain, but I’ve rarely seen multiple divisions being necessary back-to-back and I don’t want people passing around aResult<f64>
in the codebase. Then you can’t see where it went wrong anymore either.So, personally, I wouldn’t put that division operator into the stdlib, but having it available as a library, if someone needs it, would be cool, yeah.