use num_traits::Pow;
use crate::UUID;
macro_rules! impl_pow_integer_rhs {
($rhs:ty) => {
impl Pow<$rhs> for UUID {
type Output = Self;
#[inline]
fn pow(self, rhs: $rhs) -> Self::Output {
UUID::from_u128(self.to_u128().pow(u32::from(rhs)))
}
}
impl<'a> Pow<&'a $rhs> for UUID {
type Output = Self;
#[inline]
fn pow(self, rhs: &'a $rhs) -> Self::Output {
<Self as Pow<$rhs>>::pow(self, *rhs)
}
}
impl<'a> Pow<$rhs> for &'a UUID {
type Output = UUID;
#[inline]
fn pow(self, rhs: $rhs) -> Self::Output {
<UUID as Pow<$rhs>>::pow(*self, rhs)
}
}
impl<'a, 'b> Pow<&'a $rhs> for &'b UUID {
type Output = UUID;
#[inline]
fn pow(self, rhs: &'a $rhs) -> Self::Output {
<UUID as Pow<$rhs>>::pow(*self, *rhs)
}
}
};
}
impl_pow_integer_rhs!(u8);
impl_pow_integer_rhs!(u16);
impl_pow_integer_rhs!(u32);
impl Pow<usize> for UUID {
type Output = Self;
#[inline]
fn pow(self, rhs: usize) -> Self::Output {
num_traits::pow(self, rhs)
}
}
impl<'a> Pow<&'a usize> for UUID {
type Output = Self;
#[inline]
fn pow(self, rhs: &'a usize) -> Self::Output {
<Self as Pow<usize>>::pow(self, *rhs)
}
}
impl Pow<usize> for &UUID {
type Output = UUID;
#[inline]
fn pow(self, rhs: usize) -> Self::Output {
<UUID as Pow<usize>>::pow(*self, rhs)
}
}
impl<'a> Pow<&'a usize> for &UUID {
type Output = UUID;
#[inline]
fn pow(self, rhs: &'a usize) -> Self::Output {
<UUID as Pow<usize>>::pow(*self, *rhs)
}
}