macro_rules! arithmetic_trait_borrowed_to_owned {
($trait:ident, $trait_function:ident, $type:ident, $other_type:ident, $output_type:ident) => {
#[doc(hidden)]
impl $trait<$other_type> for $type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $output_type "::" $trait_function "`]."]
fn $trait_function(self, other: $other_type) -> Self::Output {
(&self).$trait_function(&other)
}
}
}
};
}
pub(crate) use arithmetic_trait_borrowed_to_owned;
macro_rules! arithmetic_trait_mixed_borrowed_owned {
($trait:ident, $trait_function:ident, $type:ident, $other_type:ident, $output_type:ident) => {
#[doc(hidden)]
impl $trait<$other_type> for &$type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $output_type "::" $trait_function "`]."]
fn $trait_function(self, other: $other_type) -> Self::Output {
self.$trait_function(&other)
}
}
}
#[doc(hidden)]
impl $trait<&$other_type> for $type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $output_type "::" $trait_function "`]."]
fn $trait_function(self, other: &$other_type) -> Self::Output {
(&self).$trait_function(other)
}
}
}
};
}
pub(crate) use arithmetic_trait_mixed_borrowed_owned;
macro_rules! arithmetic_between_types {
($trait:ident, $trait_function:ident, $type:ident, $output_type:ident, $($other_type:ident)*) => {
$(
#[doc(hidden)] impl $trait<&$other_type> for &$type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $type "::" $trait_function "`]."]
fn $trait_function(self, other: &$other_type) -> Self::Output {
self.$trait_function($output_type::from(*other))
}
}
}
arithmetic_trait_borrowed_to_owned!($trait, $trait_function, $type, $other_type, $output_type);
arithmetic_trait_mixed_borrowed_owned!($trait, $trait_function, $type, $other_type, $output_type);
#[doc(hidden)]
impl $trait<&$type> for &$other_type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $type "::" $trait_function "`]."]
fn $trait_function(self, other: &$type) -> Self::Output {
$output_type::from(*self).$trait_function(other)
}
}
}
arithmetic_trait_borrowed_to_owned!($trait, $trait_function, $other_type, $type, $output_type);
arithmetic_trait_mixed_borrowed_owned!($trait, $trait_function, $other_type, $type, $output_type);
)*
};
}
pub(crate) use arithmetic_between_types;
macro_rules! arithmetic_trait_reverse {
($trait:ident, $trait_function:ident, $type:ident, $other_type:ident, $output_type:ident) => {
#[doc(hidden)]
impl $trait<&$other_type> for &$type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`" $output_type "::" $trait_function "`]."]
fn $trait_function(self, other: &$other_type) -> Self::Output {
other.$trait_function(self)
}
}
}
};
}
pub(crate) use arithmetic_trait_reverse;
macro_rules! arithmetic_between_types_zq {
($trait:ident, $trait_function:ident, $output_type:ident, $($other_type:ident)*) => {
$(
#[doc(hidden)] impl $trait<&$other_type> for &Zq {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`Zq::" $trait_function "`]."]
fn $trait_function(self, other: &$other_type) -> Self::Output {
self.$trait_function(Zq::from((*other, &self.modulus)))
}
}
}
arithmetic_trait_borrowed_to_owned!($trait, $trait_function, Zq, $other_type, $output_type);
arithmetic_trait_mixed_borrowed_owned!($trait, $trait_function, Zq, $other_type, $output_type);
#[doc(hidden)]
impl $trait<&Zq> for &$other_type {
type Output = $output_type;
paste::paste! {
#[doc = "Documentation at [`Zq::" $trait_function "`]."]
fn $trait_function(self, other: &Zq) -> Self::Output {
other.$trait_function(Zq::from((*self, &other.modulus)))
}
}
}
arithmetic_trait_borrowed_to_owned!($trait, $trait_function, $other_type, Zq, $output_type);
arithmetic_trait_mixed_borrowed_owned!($trait, $trait_function, $other_type, Zq, $output_type);
)*
};
}
pub(crate) use arithmetic_between_types_zq;
macro_rules! arithmetic_assign_trait_borrowed_to_owned {
($trait:ident, $trait_function:ident, $type:ident, $other_type:ident) => {
impl $trait<$other_type> for $type {
paste::paste! {
#[doc = "Documentation at [`" $type "::" $trait_function "`]."]
fn $trait_function(&mut self, other: $other_type) {
self.$trait_function(&other)
}
}
}
};
}
pub(crate) use arithmetic_assign_trait_borrowed_to_owned;
macro_rules! arithmetic_assign_between_types {
($trait:ident, $trait_function:ident, $type:ident, $bridge_type:ident, $($other_type:ident)*) => {
$(
impl $trait<$other_type> for $type {
paste::paste! {
#[doc = "Documentation at [` " $type "::" $trait_function "`]."]
fn $trait_function(&mut self, other: $other_type) {
self.$trait_function($bridge_type::from(other));
}
}
}
)*
};
}
pub(crate) use arithmetic_assign_between_types;