| > First of all, they kind of dodge this later by saying "Array indexing must be properly tested" (else it can panic) -- everyone thinks they write code which is "properly tested". You're skipping half the recommendation though: > Array indexing must be properly tested, or the get method should be used to return an Option. emphasis mine > Also, in rust if we don't want to panic we need to never use array indexing and never use integer division, just to start. I mean, that's literally the block above the one you quote: > Common patterns that can cause panics are: > * using unwrap or expect, > * using assert, > * an unchecked access to an array, > * integer overflow (in debug mode), > * division by zero, > * large allocations, > * string formatting using format!. >> Rule LANG-NOPANIC >> Functions or instructions that can cause the code to panic at runtime must not be used. The bit you quote is really a additional reminder that array indexing is not panic-safe. |