rust@octodon.social ("Rust tips") wrote:
If you want your #Rustlang code to be fast and compact, avoid code that could panic.
Returning from a function instead of panicking is always going to optimize better.
https://rust.godbolt.org/z/MKW1xjrrx
This is because the optimizer fully understands function returns, and is able to reorder or coalesce them together. Panics have unique locations and major side effects that can't be touched by the optimizer, so in addition to adding extra unwinding code, panics prevent optimization of code around them.
Prefer
?over.unwrap(). Prefer iterators ora.get(…)?overa[…].