Is there any significant performance cost to using `array.get(idx).ok_or(Error::Whoops)` over `array[idx]`?

62 points Perfect-Junket-165 28 comments

And is `array.get(idx).ok_or(Error::Whoops)` faster than checking against known bounds explicitly with an `if` statement?

I'm doing a lot of indexing that doesn't lend itself nicely to an iterator. I suppose I could do a performance test, but I figured someone probably already knows the answer.

Thanks in advance <3