diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-19 03:27:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-19 03:27:01 +0200 |
| commit | 8e0a8cdecbd80df4611f722058f3b7dc2dd2aa1a (patch) | |
| tree | a34f4974577d7845d76dfedb187e906592b53b8f /library/std | |
| parent | d8bde4878a1efea6f18d63a0ee93ee25c90be551 (diff) | |
| parent | 2c2163538246ad528e57e87db021d7528060aa65 (diff) | |
| download | rust-8e0a8cdecbd80df4611f722058f3b7dc2dd2aa1a.tar.gz rust-8e0a8cdecbd80df4611f722058f3b7dc2dd2aa1a.zip | |
Rollup merge of #114977 - kpreid:modulo, r=thomcc
Add `modulo` and `mod` as doc aliases for `rem_euclid`. 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.
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/f32.rs | 1 | ||||
| -rw-r--r-- | library/std/src/f64.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index d380d95b6e7..a659b552f47 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -323,6 +323,7 @@ impl f32 { /// // limitation due to round-off error /// assert!((-f32::EPSILON).rem_euclid(3.0) != 0.0); /// ``` + #[doc(alias = "modulo", alias = "mod")] #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] #[inline] diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 1302782c5b0..721e1fb754e 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -323,6 +323,7 @@ impl f64 { /// // limitation due to round-off error /// assert!((-f64::EPSILON).rem_euclid(3.0) != 0.0); /// ``` + #[doc(alias = "modulo", alias = "mod")] #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] #[inline] |
