Re:Checked integer arithmetic in the prospect of C23
by tialaramex on Monday December 19, 2022 @07:32PM
(#34059910)
You are probably looking at it wrong. You can now write
i32::checked_add_unsigned(some_u32) and
i32::checked_sub_unsigned(some_u32)
... which I think are exactly what your parent needs.
Re:Checked integer arithmetic in the prospect of C23
by jcranmer on Monday December 19, 2022 @09:20PM
(#34060739)
u32::checked_add_signed solves one of the pairs (u32 + i32 -> u32), but there's nothing for the other one (u32 - u32 -> i32).
Re:Checked integer arithmetic in the prospect of C23
by tialaramex on Tuesday December 20, 2022 @04:27AM
(#34063604)
Good point, I'm sure this made sense to me when I wrote it, but I can't ask past me why.
[1]: https://github.com/rust-lang/rust/issues/87840