summaryrefslogtreecommitdiffstats
path: root/vendor/overload/src/unary.rs
blob: da8f6b590db6a9ad88f8429742e7600e01488888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! _overload_unary {
    (-, $($t:tt)+) => (_overload_unary_internal!(Neg, neg, $($t)+););
    (!, $($t:tt)+) => (_overload_unary_internal!(Not, not, $($t)+););
}

#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! _overload_unary_internal {
    ($op_trait:ident, $op_fn:ident, $i:ident, $t:ty, $out:ty, $body:block) => (        
        impl ops::$op_trait for $t {
            type Output = $out;
            fn $op_fn(self) -> Self::Output {
                let $i = self;
                $body
            }
        }
    );
}