4 ms·
If you want to check for overflow, then you can use the methods that explicitly check for overflow: https://doc.rust-lang.org/std/primitive.u32.html#method.che
by robot_no_421 4y ago
If you want to check for overflow, then you can use the methods that explicitly check for overflow:
https://doc.rust-lang.org/std/primitive.u32.html#method.checked_add https://doc.rust-lang.org/std/primitive.u32.html#method.chec...
So this is not an issue at all.
- codedokode 4y agoThey are long to type and hard to read. They are so inconvenient to use that nobody uses them, even developers of Rust. Take source code of Vec as an example [1]. They use wrapping addition instead of checked one. For comparison, in Swift normal arithmetic operations check for overflow. [1] https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#1773 https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#1773