#[macro_export]
macro_rules! parse_func {
($func:ident) => {
fn $func(&self) -> Self::Output {
self.apply($func)
}
};
(($func:ident, $arg:ident : $_type:ty)) => {
fn $func(&self, $arg: _type) -> self::Output {
self.apply_arg($func, $arg)
}
};
}
#[macro_export]
macro_rules! impl_math {
( $($exp:expr),* ) => {
trait Math {
type Output;
$(parse_func!($exp);)*
#[inline]
fn apply(&self, func: fn(f64) -> f64) -> Self::Output;
#[inline]
fn apply_arg<T>(&self, func: fn(f64, T) -> f64, arg: T) -> Self::Output;
}
};
}