macro_rules! forward_ref_binop_lhs {
(impl[$($gp:tt)*] $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl<$($gp)*> core::ops::$imp<$u> for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: $u) -> <Self as core::ops::$imp<$u>>::Output {
(*self).$method(rhs)
}
}
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl core::ops::$imp<$u> for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: $u) -> <Self as core::ops::$imp<$u>>::Output {
(*self).$method(rhs)
}
}
};
}
macro_rules! forward_ref_binop_rhs {
(impl[$($gp:tt)*] $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl<$($gp)*> core::ops::$imp<&$u> for $t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: &$u) -> <Self as core::ops::$imp<&$u>>::Output {
self.$method(*rhs)
}
}
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl core::ops::$imp<&$u> for $t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: &$u) -> <Self as core::ops::$imp<&$u>>::Output {
self.$method(*rhs)
}
}
};
}
macro_rules! forward_ref_binop_both {
(impl[$($gp:tt)*] $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl<$($gp)*> core::ops::$imp<&$u> for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: &$u) -> <Self as core::ops::$imp<&$u>>::Output {
(*self).$method(*rhs)
}
}
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
impl core::ops::$imp<&$u> for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp<$u>>::Output;
#[inline]
fn $method(self, rhs: &$u) -> <Self as core::ops::$imp<&$u>>::Output {
(*self).$method(*rhs)
}
}
};
}
macro_rules! forward_ref_binop {
(impl[$($gp:tt)*] $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
forward_ref_binop_lhs! { impl[$($gp)*] $imp, $method for $t, $u $(where ($($wp)*))? }
forward_ref_binop_rhs! { impl[$($gp)*] $imp, $method for $t, $u $(where ($($wp)*))? }
forward_ref_binop_both! { impl[$($gp)*] $imp, $method for $t, $u $(where ($($wp)*))? }
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty
$(where ($($wp:tt)*))?) => {
forward_ref_binop_lhs! { impl $imp, $method for $t, $u $(where ($($wp)*))? }
forward_ref_binop_rhs! { impl $imp, $method for $t, $u $(where ($($wp)*))? }
forward_ref_binop_both! { impl $imp, $method for $t, $u $(where ($($wp)*))? }
};
}
macro_rules! forward_ref_unop {
(impl[$($gp:tt)*] $imp:ident, $method:ident for $t:ty
$(where ($($wp:tt)*))?) => {
impl<$($gp)*> core::ops::$imp for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp>::Output;
#[inline]
fn $method(self) -> <Self as core::ops::$imp>::Output {
(*self).$method()
}
}
};
(impl $imp:ident, $method:ident for $t:ty
$(where ($($wp:tt)*))?) => {
impl core::ops::$imp for &$t
$(where $($wp)*)?
{
type Output = <$t as core::ops::$imp>::Output;
#[inline]
fn $method(self) -> <Self as core::ops::$imp>::Output {
(*self).$method()
}
}
};
}