diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index e7101537b298..2cf06b6d6a35 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -1770,6 +1770,7 @@ impl f128 { /// assert!(abs_difference <= f128::EPSILON); /// /// assert_eq!(f128::powi(f128::NAN, 0), 1.0); + /// assert_eq!(f128::powi(0.0, 0), 1.0); /// # } /// ``` #[inline] diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index aa8342a22ad5..51f803672e5c 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -1745,6 +1745,7 @@ impl f16 { /// assert!(abs_difference <= f16::EPSILON); /// /// assert_eq!(f16::powi(f16::NAN, 0), 1.0); + /// assert_eq!(f16::powi(0.0, 0), 1.0); /// # } /// ``` #[inline] diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 70e764de9069..6a6853670665 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -1720,6 +1720,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("assert_eq!(8", stringify!($SelfT), ".checked_pow(2), Some(64));")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".checked_pow(0), Some(1));")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);")] /// ``` @@ -1761,6 +1762,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("assert_eq!(8", stringify!($SelfT), ".strict_pow(2), 64);")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".strict_pow(0), 1);")] /// ``` /// /// The following panics because of overflow: @@ -2033,6 +2035,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("assert_eq!((-4", stringify!($SelfT), ").saturating_pow(3), -64);")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".saturating_pow(0), 1);")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(2), ", stringify!($SelfT), "::MAX);")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(3), ", stringify!($SelfT), "::MIN);")] /// ``` @@ -2377,6 +2380,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".wrapping_pow(4), 81);")] /// assert_eq!(3i8.wrapping_pow(5), -13); /// assert_eq!(3i8.wrapping_pow(6), -39); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".wrapping_pow(0), 1);")] /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] @@ -2967,6 +2971,7 @@ macro_rules! int_impl { /// /// ``` #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".overflowing_pow(4), (81, false));")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".overflowing_pow(0), (1, false));")] /// assert_eq!(3i8.overflowing_pow(5), (-13, true)); /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] @@ -3010,6 +3015,7 @@ macro_rules! int_impl { #[doc = concat!("let x: ", stringify!($SelfT), " = 2; // or any other integer type")] /// /// assert_eq!(x.pow(5), 32); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".pow(0), 1);")] /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index d38d3a1a5ad4..d638f5551fea 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -2055,6 +2055,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_pow(5), Some(32));")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".checked_pow(0), Some(1));")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);")] /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] @@ -2095,6 +2096,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".strict_pow(5), 32);")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".strict_pow(0), 1);")] /// ``` /// /// The following panics because of overflow: @@ -2269,6 +2271,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("assert_eq!(4", stringify!($SelfT), ".saturating_pow(3), 64);")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".saturating_pow(0), 1);")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_pow(2), ", stringify!($SelfT), "::MAX);")] /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] @@ -2578,6 +2581,7 @@ macro_rules! uint_impl { /// ``` #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".wrapping_pow(5), 243);")] /// assert_eq!(3u8.wrapping_pow(6), 217); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".wrapping_pow(0), 1);")] /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] @@ -3252,6 +3256,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".overflowing_pow(5), (243, false));")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".overflowing_pow(0), (1, false));")] /// assert_eq!(3u8.overflowing_pow(6), (217, true)); /// ``` #[stable(feature = "no_panic_pow", since = "1.34.0")] @@ -3293,6 +3298,7 @@ macro_rules! uint_impl { /// /// ``` #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".pow(5), 32);")] + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".pow(0), 1);")] /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")] diff --git a/library/std/src/num/f128.rs b/library/std/src/num/f128.rs index 40061d089284..3b787713afa2 100644 --- a/library/std/src/num/f128.rs +++ b/library/std/src/num/f128.rs @@ -37,6 +37,7 @@ impl f128 { /// /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0); /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0); + /// assert_eq!(f128::powf(0.0, 0.0), 1.0); /// # } /// ``` #[inline] diff --git a/library/std/src/num/f16.rs b/library/std/src/num/f16.rs index 0d43b60a62fe..4af21c95c9ba 100644 --- a/library/std/src/num/f16.rs +++ b/library/std/src/num/f16.rs @@ -37,6 +37,7 @@ impl f16 { /// /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0); /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0); + /// assert_eq!(f16::powf(0.0, 0.0), 1.0); /// # } /// ``` #[inline] diff --git a/library/std/src/num/f32.rs b/library/std/src/num/f32.rs index c9e192201aff..09ced388a339 100644 --- a/library/std/src/num/f32.rs +++ b/library/std/src/num/f32.rs @@ -308,6 +308,7 @@ impl f32 { /// assert!(abs_difference <= 1e-5); /// /// assert_eq!(f32::powi(f32::NAN, 0), 1.0); + /// assert_eq!(f32::powi(0.0, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -333,6 +334,7 @@ impl f32 { /// /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0); /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0); + /// assert_eq!(f32::powf(0.0, 0.0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] diff --git a/library/std/src/num/f64.rs b/library/std/src/num/f64.rs index 11874f9280f0..79adf076e4b1 100644 --- a/library/std/src/num/f64.rs +++ b/library/std/src/num/f64.rs @@ -308,6 +308,7 @@ impl f64 { /// assert!(abs_difference <= 1e-14); /// /// assert_eq!(f64::powi(f64::NAN, 0), 1.0); + /// assert_eq!(f64::powi(0.0, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -333,6 +334,7 @@ impl f64 { /// /// assert_eq!(f64::powf(1.0, f64::NAN), 1.0); /// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0); + /// assert_eq!(f64::powf(0.0, 0.0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"]