Arguments mixed up in documentation of rem_euclid
and div_euclid
#128857
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
Location
The documentation of
rem_euclid
anddiv_euclid
for any signed integer type, e.g.: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.rem_euclidSummary
In the "Panics" section it says "This function will panic if
rhs
is 0 or ifself
is -1 andrhs
isSelf::MIN
.", but I believe this is the wrong way around: the panic happens onMIN % -1
, not on(-1) % MIN
, as (correctly) explained inwrapping_rem_euclid
and all other related functions.Also, is there any situation where someone would want
rem_euclid
overwrapping_rem_euclid
? Mathematically,MIN % -1
should really just be 0, that it panics is more of an implementation artifact (the corresponding divisionMIN / -1
overflows). Maybe it would be a good idea to add something like "If this is a problem, usewrapping_rem_euclid
instead." to the documentation ofrem_euclid
? Though in most applicationsrhs
will probably be positive anyway.The text was updated successfully, but these errors were encountered: