3 ms·
In which case the compiler will emit the overflow or bounds checks, which is fine. If the developer is certain that a specific add operation should use uncheck
by jiggawatts 4y ago
In which case the compiler will emit the overflow or bounds checks, which is fine.
If the developer is certain that a specific add operation should use unchecked add for performance, then they can override the behaviour as a spot micro-optimisation. That then becomes a "self documenting" thing, easily found by a simple keyword search.
To give you an idea of just how rarely this is actually needed or done, there are less than a thousand uses of "unchecked_add()" in all of the Rust code on GitHub!
https://github.com/search?q=.unchecked_add%28+language%3ARust&type=code&l=Rust https://github.com/search?q=.unchecked_add%28+language%3ARus...