From 8098b3299dec6cda21eceecb8152728fe5a06cbc Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Tue, 6 Apr 2021 10:38:12 -0500 Subject: [PATCH] Add copy_sign() as alias for f32/f64::copysign() This should help the compiler emit a more helpful error message when the function is spelled the way it should have been. cc #58046 --- library/std/src/f32.rs | 1 + library/std/src/f64.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index c16d27fa1f58c..e77bdba054f46 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -196,6 +196,7 @@ impl f32 { #[must_use = "method returns a new number and does not mutate the original value"] #[inline] #[stable(feature = "copysign", since = "1.35.0")] + #[doc(alias = "copy_sign")] pub fn copysign(self, sign: f32) -> f32 { unsafe { intrinsics::copysignf32(self, sign) } } diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 4c95df5ffe04a..8e26220cf9284 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -194,8 +194,9 @@ impl f64 { /// assert!(f64::NAN.copysign(1.0).is_nan()); /// ``` #[must_use = "method returns a new number and does not mutate the original value"] - #[stable(feature = "copysign", since = "1.35.0")] #[inline] + #[stable(feature = "copysign", since = "1.35.0")] + #[doc(alias = "copy_sign")] pub fn copysign(self, sign: f64) -> f64 { unsafe { intrinsics::copysignf64(self, sign) } }