rust_numpy/
macroses.rs

1
2#[macro_export]
3macro_rules! parse_func {
4    ($func:ident) => {
5        fn $func(&self) -> Self::Output {
6            self.apply($func)
7        }
8    };
9
10    (($func:ident, $arg:ident : $_type:ty)) => {
11        fn $func(&self, $arg: _type) -> self::Output {
12            self.apply_arg($func, $arg)
13        }
14    };
15}
16
17
18#[macro_export]
19macro_rules! impl_math {
20
21    ( $($exp:expr),* ) => {
22        trait Math {
23            type Output;
24
25            $(parse_func!($exp);)*
26
27            #[inline]
28            fn apply(&self, func: fn(f64) -> f64) -> Self::Output;
29
30            #[inline]
31            fn apply_arg<T>(&self, func: fn(f64, T) -> f64, arg: T) -> Self::Output;
32
33        }
34    };
35}