@@ -1715,6 +1715,19 @@ macro_rules! int_impl {
17151715 /// ```
17161716 #[ doc = concat!( "assert_eq!(8" , stringify!( $SelfT) , ".checked_pow(2), Some(64));" ) ]
17171717 #[ doc = concat!( "assert_eq!(" , stringify!( $SelfT) , "::MAX.checked_pow(2), None);" ) ]
1718+ ///
1719+ /// // Special cases:
1720+ /// // any `self` to the power of zero always returns 1.
1721+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".checked_pow(0), Some(1));" ) ]
1722+ ///
1723+ /// // 1 to the power of any `exp` always returns 1.
1724+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".checked_pow(2), Some(1));" ) ]
1725+ ///
1726+ /// // any `self` to the power of one always returns `self`.
1727+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".checked_pow(1), Some(3));" ) ]
1728+ ///
1729+ /// // 0 to the power of any `exp` always returns 0.
1730+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".checked_pow(3), Some(0));" ) ]
17181731 /// ```
17191732
17201733 #[ stable( feature = "no_panic_pow" , since = "1.34.0" ) ]
@@ -1755,6 +1768,19 @@ macro_rules! int_impl {
17551768 ///
17561769 /// ```
17571770 #[ doc = concat!( "assert_eq!(8" , stringify!( $SelfT) , ".strict_pow(2), 64);" ) ]
1771+ ///
1772+ /// // Special cases:
1773+ /// // any `self` to the power of zero always returns 1.
1774+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".strict_pow(0), 1);" ) ]
1775+ ///
1776+ /// // 1 to the power of any `exp` always returns 1.
1777+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".strict_pow(2), 1);" ) ]
1778+ ///
1779+ /// // any `self` to the power of one always returns `self`.
1780+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".strict_pow(1), 3);" ) ]
1781+ ///
1782+ /// // 0 to the power of any `exp` always returns 0.
1783+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".strict_pow(3), 0);" ) ]
17581784 /// ```
17591785 ///
17601786 /// The following panics because of overflow:
@@ -2029,6 +2055,19 @@ macro_rules! int_impl {
20292055 #[ doc = concat!( "assert_eq!((-4" , stringify!( $SelfT) , ").saturating_pow(3), -64);" ) ]
20302056 #[ doc = concat!( "assert_eq!(" , stringify!( $SelfT) , "::MIN.saturating_pow(2), " , stringify!( $SelfT) , "::MAX);" ) ]
20312057 #[ doc = concat!( "assert_eq!(" , stringify!( $SelfT) , "::MIN.saturating_pow(3), " , stringify!( $SelfT) , "::MIN);" ) ]
2058+ ///
2059+ /// // Special cases:
2060+ /// // any `self` to the power of zero always returns 1.
2061+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".saturating_pow(0), 1);" ) ]
2062+ ///
2063+ /// // 1 to the power of any `exp` always returns 1.
2064+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".saturating_pow(2), 1);" ) ]
2065+ ///
2066+ /// // any `self` to the power of one always returns `self`.
2067+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".saturating_pow(1), 3);" ) ]
2068+ ///
2069+ /// // 0 to the power of any `exp` always returns 0.
2070+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".saturating_pow(3), 0);" ) ]
20322071 /// ```
20332072 #[ stable( feature = "no_panic_pow" , since = "1.34.0" ) ]
20342073 #[ rustc_const_stable( feature = "const_int_pow" , since = "1.50.0" ) ]
@@ -2371,6 +2410,19 @@ macro_rules! int_impl {
23712410 #[ doc = concat!( "assert_eq!(3" , stringify!( $SelfT) , ".wrapping_pow(4), 81);" ) ]
23722411 /// assert_eq!(3i8.wrapping_pow(5), -13);
23732412 /// assert_eq!(3i8.wrapping_pow(6), -39);
2413+ ///
2414+ /// // Special cases:
2415+ /// // any `self` to the power of zero always returns 1.
2416+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".wrapping_pow(0), 1);" ) ]
2417+ ///
2418+ /// // 1 to the power of any `exp` always returns 1.
2419+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".wrapping_pow(2), 1);" ) ]
2420+ ///
2421+ /// // any `self` to the power of one always returns `self`.
2422+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".wrapping_pow(1), 3);" ) ]
2423+ ///
2424+ /// // 0 to the power of any `exp` always returns 0.
2425+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".wrapping_pow(3), 0);" ) ]
23742426 /// ```
23752427 #[ stable( feature = "no_panic_pow" , since = "1.34.0" ) ]
23762428 #[ rustc_const_stable( feature = "const_int_pow" , since = "1.50.0" ) ]
@@ -2962,6 +3014,20 @@ macro_rules! int_impl {
29623014 /// ```
29633015 #[ doc = concat!( "assert_eq!(3" , stringify!( $SelfT) , ".overflowing_pow(4), (81, false));" ) ]
29643016 /// assert_eq!(3i8.overflowing_pow(5), (-13, true));
3017+ ///
3018+ /// // Special cases:
3019+ /// // any `self` to the power of zero always returns 1.
3020+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".overflowing_pow(0), (1, false));" ) ]
3021+ ///
3022+ /// // 1 to the power of any `exp` always returns 1.
3023+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".overflowing_pow(2), (1, false));" ) ]
3024+ ///
3025+ /// // any `self` to the power of one always returns `self`.
3026+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".overflowing_pow(1), (3, false));" ) ]
3027+ ///
3028+ /// // 0 to the power of any `exp` always returns 0.
3029+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".overflowing_pow(3), (0, false));" ) ]
3030+
29653031 /// ```
29663032 #[ stable( feature = "no_panic_pow" , since = "1.34.0" ) ]
29673033 #[ rustc_const_stable( feature = "const_int_pow" , since = "1.50.0" ) ]
@@ -3004,6 +3070,19 @@ macro_rules! int_impl {
30043070 #[ doc = concat!( "let x: " , stringify!( $SelfT) , " = 2; // or any other integer type" ) ]
30053071 ///
30063072 /// assert_eq!(x.pow(5), 32);
3073+ ///
3074+ /// // Special cases:
3075+ /// // any `self` to the power of zero always returns 1.
3076+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".pow(0), 1);" ) ]
3077+ ///
3078+ /// // 1 to the power of any `exp` always returns 1.
3079+ #[ doc = concat!( "assert_eq!(1_" , stringify!( $SelfT) , ".pow(2), 1);" ) ]
3080+ ///
3081+ /// // any `self` to the power of one always returns `self`.
3082+ #[ doc = concat!( "assert_eq!(3_" , stringify!( $SelfT) , ".pow(1), 3);" ) ]
3083+ ///
3084+ /// // 0 to the power of any `exp` always returns 0.
3085+ #[ doc = concat!( "assert_eq!(0_" , stringify!( $SelfT) , ".pow(3), 0);" ) ]
30073086 /// ```
30083087 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
30093088 #[ rustc_const_stable( feature = "const_int_pow" , since = "1.50.0" ) ]
0 commit comments