feat: overload operations of expressions for easy DSL
This commit is contained in:
parent
b56327a3a2
commit
84f8b2a093
3 changed files with 255 additions and 1 deletions
32
argus-core/src/expr/internal_macros.rs
Normal file
32
argus-core/src/expr/internal_macros.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
macro_rules! forward_box_binop {
|
||||
(impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
|
||||
impl $imp<$u> for Box<$t> {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(*self, other)
|
||||
}
|
||||
}
|
||||
|
||||
impl $imp<Box<$u>> for $t {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn $method(self, other: Box<$u>) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(self, *other)
|
||||
}
|
||||
}
|
||||
|
||||
impl $imp<Box<$u>> for Box<$t> {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn $method(self, other: Box<$u>) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(*self, *other)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use forward_box_binop;
|
||||
Loading…
Add table
Add a link
Reference in a new issue