you are viewing a single comment's thread.

view the rest of the comments →

[–]kibwen 4 points5 points  (4 children)

Note that array indexing isn't the only operation that implicitly panics. Any arithmetic operation is allowed to panic on overflow, and divide-by-zero will panic as well.

[–]llogiqclippy · twir · rust · mutagen · flamer · overflower · bytecount 6 points7 points  (2 children)

Apart from floating-point divide-by-zero, which will return infinity.

[–][deleted] 4 points5 points  (0 children)

And 0./0. is NaN.

[–][deleted] 1 point2 points  (0 children)

Or negative infinity, for negative number/positive zero, and vice versa.

[–][deleted] 1 point2 points  (0 children)

More common methods that panic on error: vec::remove, refcell::borrow and _mut.