Turn underflow, out of bound to Err

Consider this block of code:

pub fn foo( ... ) -> Result<T, My_Err> {

Besides "be really careful", is there a way to ensure all out-of-bound array indexing & usize underflow (x: usize = 3; x - 5) to result in My_Err instead of panic ?

Clippy has lints for this. Check out clippy::indexing_slicing and clippy::arithmetic_side_effects.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.