Impl DynNode

This commit is contained in:
Dennis
2022-08-22 17:18:26 +02:00
committed by Keavon Chambers
parent f73836b838
commit 71f12db1e6
16 changed files with 433 additions and 84 deletions

View File

@@ -11,6 +11,24 @@ impl<'n, L: Add<R, Output = O> + 'n, R, O: 'n> Node<(L, R)> for AddNode {
input.0 + input.1
}
}
impl<'n, L: Add<R, Output = O> + 'n, R, O: 'n> Node<(L, R)> for &'n AddNode {
type Output = <L as Add<R>>::Output;
fn eval(self, input: (L, R)) -> Self::Output {
input.0 + input.1
}
}
impl<'n, L: Add<R, Output = O> + 'n + Copy, R: Copy, O: 'n> Node<&'n (L, R)> for AddNode {
type Output = <L as Add<R>>::Output;
fn eval(self, input: &'n (L, R)) -> Self::Output {
input.0 + input.1
}
}
impl<'n, L: Add<R, Output = O> + 'n + Copy, R: Copy, O: 'n> Node<&'n (L, R)> for &'n AddNode {
type Output = <L as Add<R>>::Output;
fn eval(self, input: &'n (L, R)) -> Self::Output {
input.0 + input.1
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CloneNode;
@@ -82,7 +100,7 @@ pub struct DupNode;
impl<'n, T: Clone + 'n> Node<T> for DupNode {
type Output = (T, T);
fn eval(self, input: T) -> Self::Output {
(input.clone(), input) //TODO: use Copy/Clone implementation
(input.clone(), input)
}
}
@@ -95,6 +113,12 @@ impl<'n, T: 'n> Node<T> for IdNode {
input
}
}
impl<'n, T: 'n> Node<T> for &'n IdNode {
type Output = T;
fn eval(self, input: T) -> Self::Output {
input
}
}
pub struct MapResultNode<MN, I, E>(pub MN, pub PhantomData<(I, E)>);