Description
Location
The documentation of rem_euclid
and div_euclid
for any signed integer type, e.g.: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.rem_euclid
Summary
In the "Panics" section it says "This function will panic if rhs
is 0 or if self
is -1 and rhs
is Self::MIN
.", but I believe this is the wrong way around: the panic happens on MIN % -1
, not on (-1) % MIN
, as (correctly) explained in wrapping_rem_euclid
and all other related functions.
Also, is there any situation where someone would want rem_euclid
over wrapping_rem_euclid
? Mathematically, MIN % -1
should really just be 0, that it panics is more of an implementation artifact (the corresponding division MIN / -1
overflows). Maybe it would be a good idea to add something like "If this is a problem, use wrapping_rem_euclid
instead." to the documentation of rem_euclid
? Though in most applications rhs
will probably be positive anyway.