Hacker News new | ask | show | jobs
by quietbritishjim 2164 days ago
Seems a pity they didn't add a built-in at the same time that's a bit more nuanced. It could maybe return an enum with Success(value), Underflow, Overflow and NaN. That way it's up to the coder to decide whether they want a saturating cast or to check the result explicitly.
1 comments

There are conversations about doing exactly that with `.try_into()` doing exactly that.