-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add modulo
and mod
as doc aliases for rem_euclid
.
#114977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When I was learning Rust I looked for “a modulo function” and couldn’t find one, so thought I had to write my own; it wasn't at all obvious that a function with “rem” in the name was the function I wanted. Hopefully this will save the next learner from that. However, it does have the disadvantage that the top results in rustdoc for “mod” are now these aliases instead of the Rust keyword, which probably isn't ideal.
r? @thomcc (rustbot has picked a reviewer for you, use r? to override) |
Uh, hm. |
I think this is fine for modulo, but perhaps not for mod (for the reason you mention). |
Let me present further argument for keeping “mod” in particular:
However, I'm happy to adjust this PR to only include “modulo” if that is unconvincing. |
Hm, I think this is fine. This is probably my pick for the worst-named function in the stdlib anyway. @bors r+ rollup |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114953 (Add myself back to review rotation) - rust-lang#114958 (`ignore-cross-compile` on `optimization-remarks-dir-pgo` test) - rust-lang#114971 (Add doc aliases for trigonometry and other f32,f64 methods.) - rust-lang#114972 (Add a test to check that inline const is in required_consts) - rust-lang#114977 (Add `modulo` and `mod` as doc aliases for `rem_euclid`.) r? `@ghost` `@rustbot` modify labels: rollup
docs: add alias log1p to ln_1p This is what the function is called in several other languages: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p * https://numpy.org/doc/stable/reference/generated/numpy.log1p.html * https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/log1p-log1pf-log1pl2?view=msvc-170 It also confused people at URLO: https://users.rust-lang.org/t/64-bit-trigonometry/98599/27 Similar to: * rust-lang#114971 * rust-lang#114977
When I was learning Rust I looked for “a modulo function” and couldn’t find one, so thought I had to write my own; it wasn't at all obvious that a function with “rem” in the name was the function I wanted. Hopefully this will save the next learner from that.
However, it does have the disadvantage that the top results in rustdoc for “mod” are now these aliases instead of the Rust keyword, which probably isn't ideal.