num_traits/
pow.rs

1use crate::{CheckedMul, One};
2use core::num::Wrapping;
3use core::ops::Mul;
4
5/// Binary operator for raising a value to a power.
6pub trait Pow<RHS> {
7    /// The result after applying the operator.
8    type Output;
9
10    /// Returns `self` to the power `rhs`.
11    ///
12    /// # Examples
13    ///
14    /// ```
15    /// use num_traits::Pow;
16    /// assert_eq!(Pow::pow(10u32, 2u32), 100);
17    /// ```
18    fn pow(self, rhs: RHS) -> Self::Output;
19}
20
21macro_rules! pow_impl {
22    ($t:ty) => {
23        pow_impl!($t, u8);
24        pow_impl!($t, usize);
25
26        // FIXME: these should be possible
27        // pow_impl!($t, u16);
28        // pow_impl!($t, u32);
29        // pow_impl!($t, u64);
30    };
31    ($t:ty, $rhs:ty) => {
32        pow_impl!($t, $rhs, usize, pow);
33    };
34    ($t:ty, $rhs:ty, $desired_rhs:ty, $method:expr) => {
35        impl Pow<$rhs> for $t {
36            type Output = $t;
37            #[inline]
38            fn pow(self, rhs: $rhs) -> $t {
39                ($method)(self, <$desired_rhs>::from(rhs))
40            }
41        }
42
43        impl<'a> Pow<&'a $rhs> for $t {
44            type Output = $t;
45            #[inline]
46            fn pow(self, rhs: &'a $rhs) -> $t {
47                ($method)(self, <$desired_rhs>::from(*rhs))
48            }
49        }
50
51        impl<'a> Pow<$rhs> for &'a $t {
52            type Output = $t;
53            #[inline]
54            fn pow(self, rhs: $rhs) -> $t {
55                ($method)(*self, <$desired_rhs>::from(rhs))
56            }
57        }
58
59        impl<'a, 'b> Pow<&'a $rhs> for &'b $t {
60            type Output = $t;
61            #[inline]
62            fn pow(self, rhs: &'a $rhs) -> $t {
63                ($method)(*self, <$desired_rhs>::from(*rhs))
64            }
65        }
66    };
67}
68
69impl Pow<u8> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u8) -> u8 { (u8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u8 { (u8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u8) -> u8 { (u8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u8 { (u8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u8, u8, u32, u8::pow);
70impl Pow<u16> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u16) -> u8 { (u8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u8 { (u8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u16) -> u8 { (u8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u8 { (u8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u8, u16, u32, u8::pow);
71impl Pow<u32> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u32) -> u8 { (u8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u8 { (u8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: u32) -> u8 { (u8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u8 { (u8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u8, u32, u32, u8::pow);
72impl Pow<usize> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: usize) -> u8 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u8 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: usize) -> u8 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b u8 {
    type Output = u8;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u8 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(u8, usize);
73impl Pow<u8> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u8) -> i8 { (i8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i8 { (i8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u8) -> i8 { (i8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i8 { (i8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i8, u8, u32, i8::pow);
74impl Pow<u16> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u16) -> i8 { (i8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i8 { (i8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u16) -> i8 { (i8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i8 { (i8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i8, u16, u32, i8::pow);
75impl Pow<u32> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u32) -> i8 { (i8::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i8 { (i8::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: u32) -> i8 { (i8::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i8 { (i8::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i8, u32, u32, i8::pow);
76impl Pow<usize> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: usize) -> i8 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i8 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: usize) -> i8 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b i8 {
    type Output = i8;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i8 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(i8, usize);
77impl Pow<u8> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u8) -> u16 { (u16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u16 { (u16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u8) -> u16 { (u16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u16 { (u16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u16, u8, u32, u16::pow);
78impl Pow<u16> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u16) -> u16 { (u16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u16 { (u16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u16) -> u16 { (u16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u16 { (u16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u16, u16, u32, u16::pow);
79impl Pow<u32> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u32) -> u16 { (u16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u16 { (u16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: u32) -> u16 { (u16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u16 { (u16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u16, u32, u32, u16::pow);
80impl Pow<usize> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: usize) -> u16 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u16 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: usize) -> u16 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b u16 {
    type Output = u16;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u16 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(u16, usize);
81impl Pow<u8> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u8) -> i16 { (i16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i16 { (i16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u8) -> i16 { (i16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i16 { (i16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i16, u8, u32, i16::pow);
82impl Pow<u16> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u16) -> i16 { (i16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i16 { (i16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u16) -> i16 { (i16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i16 { (i16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i16, u16, u32, i16::pow);
83impl Pow<u32> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u32) -> i16 { (i16::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i16 { (i16::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: u32) -> i16 { (i16::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i16 { (i16::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i16, u32, u32, i16::pow);
84impl Pow<usize> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: usize) -> i16 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i16 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: usize) -> i16 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b i16 {
    type Output = i16;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i16 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(i16, usize);
85impl Pow<u8> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u8) -> u32 { (u32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u32 { (u32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u8) -> u32 { (u32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u32 { (u32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u32, u8, u32, u32::pow);
86impl Pow<u16> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u16) -> u32 { (u32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u32 { (u32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u16) -> u32 { (u32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u32 { (u32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u32, u16, u32, u32::pow);
87impl Pow<u32> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u32) -> u32 { (u32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u32 { (u32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: u32) -> u32 { (u32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u32 { (u32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u32, u32, u32, u32::pow);
88impl Pow<usize> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: usize) -> u32 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u32 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: usize) -> u32 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b u32 {
    type Output = u32;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u32 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(u32, usize);
89impl Pow<u8> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u8) -> i32 { (i32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i32 { (i32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u8) -> i32 { (i32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i32 { (i32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i32, u8, u32, i32::pow);
90impl Pow<u16> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u16) -> i32 { (i32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i32 { (i32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u16) -> i32 { (i32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i32 { (i32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i32, u16, u32, i32::pow);
91impl Pow<u32> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u32) -> i32 { (i32::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i32 { (i32::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: u32) -> i32 { (i32::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i32 { (i32::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i32, u32, u32, i32::pow);
92impl Pow<usize> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: usize) -> i32 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i32 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: usize) -> i32 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b i32 {
    type Output = i32;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i32 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(i32, usize);
93impl Pow<u8> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u8) -> u64 { (u64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u64 { (u64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u8) -> u64 { (u64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u64 { (u64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u64, u8, u32, u64::pow);
94impl Pow<u16> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u16) -> u64 { (u64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u64 { (u64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u16) -> u64 { (u64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u64 { (u64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u64, u16, u32, u64::pow);
95impl Pow<u32> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u32) -> u64 { (u64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u64 { (u64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: u32) -> u64 { (u64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u64 { (u64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(u64, u32, u32, u64::pow);
96impl Pow<usize> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: usize) -> u64 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u64 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: usize) -> u64 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b u64 {
    type Output = u64;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u64 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(u64, usize);
97impl Pow<u8> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u8) -> i64 { (i64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i64 { (i64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u8) -> i64 { (i64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i64 { (i64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i64, u8, u32, i64::pow);
98impl Pow<u16> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u16) -> i64 { (i64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i64 { (i64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u16> for &'a i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u16) -> i64 { (i64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i64 { (i64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i64, u16, u32, i64::pow);
99impl Pow<u32> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u32) -> i64 { (i64::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i64 { (i64::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u32> for &'a i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: u32) -> i64 { (i64::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i64 { (i64::pow)(*self, <u32>::from(*rhs)) }
}pow_impl!(i64, u32, u32, i64::pow);
100impl Pow<usize> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: usize) -> i64 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i64 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: usize) -> i64 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b i64 {
    type Output = i64;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i64 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(i64, usize);
101
102impl Pow<u8> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u8) -> u128 { (u128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u128 { (u128::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u8) -> u128 { (u128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u8) -> u128 {
        (u128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(u128, u8, u32, u128::pow);
103impl Pow<u16> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u16) -> u128 { (u128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u128 {
        (u128::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u16) -> u128 { (u128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u16) -> u128 {
        (u128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(u128, u16, u32, u128::pow);
104impl Pow<u32> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u32) -> u128 { (u128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u128 {
        (u128::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u32> for &'a u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: u32) -> u128 { (u128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a u32) -> u128 {
        (u128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(u128, u32, u32, u128::pow);
105impl Pow<usize> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: usize) -> u128 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u128 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: usize) -> u128 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b u128 {
    type Output = u128;
    #[inline]
    fn pow(self, rhs: &'a usize) -> u128 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(u128, usize);
106
107impl Pow<u8> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u8) -> i128 { (i128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i128 { (i128::pow)(self, <u32>::from(*rhs)) }
}
impl<'a> Pow<u8> for &'a i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u8) -> i128 { (i128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u8) -> i128 {
        (i128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(i128, u8, u32, i128::pow);
108impl Pow<u16> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u16) -> i128 { (i128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i128 {
        (i128::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u16) -> i128 { (i128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u16) -> i128 {
        (i128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(i128, u16, u32, i128::pow);
109impl Pow<u32> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u32) -> i128 { (i128::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i128 {
        (i128::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u32> for &'a i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: u32) -> i128 { (i128::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a u32) -> i128 {
        (i128::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(i128, u32, u32, i128::pow);
110impl Pow<usize> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: usize) -> i128 { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i128 { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: usize) -> i128 { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b i128 {
    type Output = i128;
    #[inline]
    fn pow(self, rhs: &'a usize) -> i128 { (pow)(*self, <usize>::from(*rhs)) }
}pow_impl!(i128, usize);
111
112impl Pow<u8> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u8) -> usize { (usize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u8) -> usize {
        (usize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u8> for &'a usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u8) -> usize { (usize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u8) -> usize {
        (usize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(usize, u8, u32, usize::pow);
113impl Pow<u16> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u16) -> usize { (usize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u16) -> usize {
        (usize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u16) -> usize { (usize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u16) -> usize {
        (usize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(usize, u16, u32, usize::pow);
114impl Pow<u32> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u32) -> usize { (usize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u32) -> usize {
        (usize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u32> for &'a usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: u32) -> usize { (usize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a u32) -> usize {
        (usize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(usize, u32, u32, usize::pow);
115impl Pow<usize> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: usize) -> usize { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a usize) -> usize { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: usize) -> usize { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b usize {
    type Output = usize;
    #[inline]
    fn pow(self, rhs: &'a usize) -> usize {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(usize, usize);
116impl Pow<u8> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u8) -> isize { (isize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u8> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u8) -> isize {
        (isize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u8> for &'a isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u8) -> isize { (isize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u8> for &'b isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u8) -> isize {
        (isize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(isize, u8, u32, isize::pow);
117impl Pow<u16> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u16) -> isize { (isize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u16> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u16) -> isize {
        (isize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u16) -> isize { (isize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u16> for &'b isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u16) -> isize {
        (isize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(isize, u16, u32, isize::pow);
118impl Pow<u32> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u32) -> isize { (isize::pow)(self, <u32>::from(rhs)) }
}
impl<'a> Pow<&'a u32> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u32) -> isize {
        (isize::pow)(self, <u32>::from(*rhs))
    }
}
impl<'a> Pow<u32> for &'a isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: u32) -> isize { (isize::pow)(*self, <u32>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a u32> for &'b isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a u32) -> isize {
        (isize::pow)(*self, <u32>::from(*rhs))
    }
}pow_impl!(isize, u32, u32, isize::pow);
119impl Pow<usize> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: usize) -> isize { (pow)(self, <usize>::from(rhs)) }
}
impl<'a> Pow<&'a usize> for isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a usize) -> isize { (pow)(self, <usize>::from(*rhs)) }
}
impl<'a> Pow<usize> for &'a isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: usize) -> isize { (pow)(*self, <usize>::from(rhs)) }
}
impl<'a, 'b> Pow<&'a usize> for &'b isize {
    type Output = isize;
    #[inline]
    fn pow(self, rhs: &'a usize) -> isize {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(isize, usize);
120impl Pow<usize> for Wrapping<u8> {
    type Output = Wrapping<u8>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u8> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<u8> {
    type Output = Wrapping<u8>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u8> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<u8> {
    type Output = Wrapping<u8>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u8> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<u8> {
    type Output = Wrapping<u8>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u8> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<u8>);
121impl Pow<usize> for Wrapping<i8> {
    type Output = Wrapping<i8>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i8> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<i8> {
    type Output = Wrapping<i8>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i8> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<i8> {
    type Output = Wrapping<i8>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i8> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<i8> {
    type Output = Wrapping<i8>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i8> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<i8>);
122impl Pow<usize> for Wrapping<u16> {
    type Output = Wrapping<u16>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u16> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<u16> {
    type Output = Wrapping<u16>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u16> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<u16> {
    type Output = Wrapping<u16>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u16> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<u16> {
    type Output = Wrapping<u16>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u16> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<u16>);
123impl Pow<usize> for Wrapping<i16> {
    type Output = Wrapping<i16>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i16> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<i16> {
    type Output = Wrapping<i16>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i16> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<i16> {
    type Output = Wrapping<i16>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i16> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<i16> {
    type Output = Wrapping<i16>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i16> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<i16>);
124impl Pow<usize> for Wrapping<u32> {
    type Output = Wrapping<u32>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u32> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<u32> {
    type Output = Wrapping<u32>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u32> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<u32> {
    type Output = Wrapping<u32>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u32> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<u32> {
    type Output = Wrapping<u32>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u32> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<u32>);
125impl Pow<usize> for Wrapping<i32> {
    type Output = Wrapping<i32>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i32> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<i32> {
    type Output = Wrapping<i32>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i32> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<i32> {
    type Output = Wrapping<i32>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i32> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<i32> {
    type Output = Wrapping<i32>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i32> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<i32>);
126impl Pow<usize> for Wrapping<u64> {
    type Output = Wrapping<u64>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u64> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<u64> {
    type Output = Wrapping<u64>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u64> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<u64> {
    type Output = Wrapping<u64>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u64> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<u64> {
    type Output = Wrapping<u64>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u64> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<u64>);
127impl Pow<usize> for Wrapping<i64> {
    type Output = Wrapping<i64>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i64> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<i64> {
    type Output = Wrapping<i64>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i64> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<i64> {
    type Output = Wrapping<i64>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i64> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<i64> {
    type Output = Wrapping<i64>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i64> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<i64>);
128impl Pow<usize> for Wrapping<u128> {
    type Output = Wrapping<u128>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u128> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<u128> {
    type Output = Wrapping<u128>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u128> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<u128> {
    type Output = Wrapping<u128>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<u128> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<u128> {
    type Output = Wrapping<u128>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<u128> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<u128>);
129impl Pow<usize> for Wrapping<i128> {
    type Output = Wrapping<i128>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i128> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<i128> {
    type Output = Wrapping<i128>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i128> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<i128> {
    type Output = Wrapping<i128>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<i128> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<i128> {
    type Output = Wrapping<i128>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<i128> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<i128>);
130impl Pow<usize> for Wrapping<usize> {
    type Output = Wrapping<usize>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<usize> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<usize> {
    type Output = Wrapping<usize>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<usize> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<usize> {
    type Output = Wrapping<usize>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<usize> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<usize> {
    type Output = Wrapping<usize>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<usize> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<usize>);
131impl Pow<usize> for Wrapping<isize> {
    type Output = Wrapping<isize>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<isize> {
        (pow)(self, <usize>::from(rhs))
    }
}
impl<'a> Pow<&'a usize> for Wrapping<isize> {
    type Output = Wrapping<isize>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<isize> {
        (pow)(self, <usize>::from(*rhs))
    }
}
impl<'a> Pow<usize> for &'a Wrapping<isize> {
    type Output = Wrapping<isize>;
    #[inline]
    fn pow(self, rhs: usize) -> Wrapping<isize> {
        (pow)(*self, <usize>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a usize> for &'b Wrapping<isize> {
    type Output = Wrapping<isize>;
    #[inline]
    fn pow(self, rhs: &'a usize) -> Wrapping<isize> {
        (pow)(*self, <usize>::from(*rhs))
    }
}pow_impl!(Wrapping<isize>);
132
133// FIXME: these should be possible
134// pow_impl!(u8, u64);
135// pow_impl!(i16, u64);
136// pow_impl!(i8, u64);
137// pow_impl!(u16, u64);
138// pow_impl!(u32, u64);
139// pow_impl!(i32, u64);
140// pow_impl!(u64, u64);
141// pow_impl!(i64, u64);
142// pow_impl!(usize, u64);
143// pow_impl!(isize, u64);
144
145#[cfg(any(feature = "std", feature = "libm"))]
146mod float_impls {
147    use super::Pow;
148    use crate::Float;
149
150    impl Pow<i8> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i8) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i8> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i8) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i8> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i8) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i8> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i8) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f32, i8, i32, <f32 as Float>::powi);
151    impl Pow<u8> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: u8) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a u8> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<u8> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: u8) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a u8> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a u8) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f32, u8, i32, <f32 as Float>::powi);
152    impl Pow<i16> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i16) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i16> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i16) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i16> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i16) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i16> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i16) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f32, i16, i32, <f32 as Float>::powi);
153    impl Pow<u16> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: u16) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a u16> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: u16) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a u16> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a u16) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f32, u16, i32, <f32 as Float>::powi);
154    impl Pow<i32> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i32) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i32> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i32) -> f32 {
        (<f32 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i32> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: i32) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i32> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a i32) -> f32 {
        (<f32 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f32, i32, i32, <f32 as Float>::powi);
155    impl Pow<i8> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i8) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i8> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i8) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i8> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i8) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i8> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i8) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f64, i8, i32, <f64 as Float>::powi);
156    impl Pow<u8> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: u8) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a u8> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<u8> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: u8) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a u8> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a u8) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f64, u8, i32, <f64 as Float>::powi);
157    impl Pow<i16> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i16) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i16> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i16) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i16> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i16) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i16> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i16) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f64, i16, i32, <f64 as Float>::powi);
158    impl Pow<u16> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: u16) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a u16> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<u16> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: u16) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a u16> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a u16) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f64, u16, i32, <f64 as Float>::powi);
159    impl Pow<i32> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i32) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(rhs))
    }
}
impl<'a> Pow<&'a i32> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i32) -> f64 {
        (<f64 as Float>::powi)(self, <i32>::from(*rhs))
    }
}
impl<'a> Pow<i32> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: i32) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a i32> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a i32) -> f64 {
        (<f64 as Float>::powi)(*self, <i32>::from(*rhs))
    }
}pow_impl!(f64, i32, i32, <f64 as Float>::powi);
160    impl Pow<f32> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: f32) -> f32 {
        (<f32 as Float>::powf)(self, <f32>::from(rhs))
    }
}
impl<'a> Pow<&'a f32> for f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a f32) -> f32 {
        (<f32 as Float>::powf)(self, <f32>::from(*rhs))
    }
}
impl<'a> Pow<f32> for &'a f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: f32) -> f32 {
        (<f32 as Float>::powf)(*self, <f32>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a f32> for &'b f32 {
    type Output = f32;
    #[inline]
    fn pow(self, rhs: &'a f32) -> f32 {
        (<f32 as Float>::powf)(*self, <f32>::from(*rhs))
    }
}pow_impl!(f32, f32, f32, <f32 as Float>::powf);
161    impl Pow<f32> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: f32) -> f64 {
        (<f64 as Float>::powf)(self, <f64>::from(rhs))
    }
}
impl<'a> Pow<&'a f32> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a f32) -> f64 {
        (<f64 as Float>::powf)(self, <f64>::from(*rhs))
    }
}
impl<'a> Pow<f32> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: f32) -> f64 {
        (<f64 as Float>::powf)(*self, <f64>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a f32> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a f32) -> f64 {
        (<f64 as Float>::powf)(*self, <f64>::from(*rhs))
    }
}pow_impl!(f64, f32, f64, <f64 as Float>::powf);
162    impl Pow<f64> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: f64) -> f64 {
        (<f64 as Float>::powf)(self, <f64>::from(rhs))
    }
}
impl<'a> Pow<&'a f64> for f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a f64) -> f64 {
        (<f64 as Float>::powf)(self, <f64>::from(*rhs))
    }
}
impl<'a> Pow<f64> for &'a f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: f64) -> f64 {
        (<f64 as Float>::powf)(*self, <f64>::from(rhs))
    }
}
impl<'a, 'b> Pow<&'a f64> for &'b f64 {
    type Output = f64;
    #[inline]
    fn pow(self, rhs: &'a f64) -> f64 {
        (<f64 as Float>::powf)(*self, <f64>::from(*rhs))
    }
}pow_impl!(f64, f64, f64, <f64 as Float>::powf);
163}
164
165/// Raises a value to the power of exp, using exponentiation by squaring.
166///
167/// Note that `0⁰` (`pow(0, 0)`) returns `1`. Mathematically this is undefined.
168///
169/// # Example
170///
171/// ```rust
172/// use num_traits::pow;
173///
174/// assert_eq!(pow(2i8, 4), 16);
175/// assert_eq!(pow(6u8, 3), 216);
176/// assert_eq!(pow(0u8, 0), 1); // Be aware if this case affects you
177/// ```
178#[inline]
179pub fn pow<T: Clone + One + Mul<T, Output = T>>(mut base: T, mut exp: usize) -> T {
180    if exp == 0 {
181        return T::one();
182    }
183
184    while exp & 1 == 0 {
185        base = base.clone() * base;
186        exp >>= 1;
187    }
188    if exp == 1 {
189        return base;
190    }
191
192    let mut acc = base.clone();
193    while exp > 1 {
194        exp >>= 1;
195        base = base.clone() * base;
196        if exp & 1 == 1 {
197            acc = acc * base.clone();
198        }
199    }
200    acc
201}
202
203/// Raises a value to the power of exp, returning `None` if an overflow occurred.
204///
205/// Note that `0⁰` (`checked_pow(0, 0)`) returns `Some(1)`. Mathematically this is undefined.
206///
207/// Otherwise same as the `pow` function.
208///
209/// # Example
210///
211/// ```rust
212/// use num_traits::checked_pow;
213///
214/// assert_eq!(checked_pow(2i8, 4), Some(16));
215/// assert_eq!(checked_pow(7i8, 8), None);
216/// assert_eq!(checked_pow(7u32, 8), Some(5_764_801));
217/// assert_eq!(checked_pow(0u32, 0), Some(1)); // Be aware if this case affect you
218/// ```
219#[inline]
220pub fn checked_pow<T: Clone + One + CheckedMul>(mut base: T, mut exp: usize) -> Option<T> {
221    if exp == 0 {
222        return Some(T::one());
223    }
224
225    while exp & 1 == 0 {
226        base = base.checked_mul(&base)?;
227        exp >>= 1;
228    }
229    if exp == 1 {
230        return Some(base);
231    }
232
233    let mut acc = base.clone();
234    while exp > 1 {
235        exp >>= 1;
236        base = base.checked_mul(&base)?;
237        if exp & 1 == 1 {
238            acc = acc.checked_mul(&base)?;
239        }
240    }
241    Some(acc)
242}