Simplify node trait definition (#1146)

* Simplify node trait
This commit is contained in:
Dennis Kobert
2023-04-17 23:42:22 +02:00
committed by Keavon Chambers
parent 1d6c4f13dd
commit 76c754d38a
11 changed files with 47 additions and 105 deletions

View File

@@ -8,7 +8,7 @@ pub struct IntNode<const N: u32>;
impl<'i, const N: u32> Node<'i, ()> for IntNode<N> {
type Output = u32;
fn eval<'s: 'i>(&'s self, _input: ()) -> Self::Output {
fn eval(&'i self, _input: ()) -> Self::Output {
N
}
}
@@ -18,7 +18,7 @@ pub struct ValueNode<T>(pub T);
impl<'i, T: 'i> Node<'i, ()> for ValueNode<T> {
type Output = &'i T;
fn eval<'s: 'i>(&'s self, _input: ()) -> Self::Output {
fn eval(&'i self, _input: ()) -> Self::Output {
&self.0
}
}
@@ -46,7 +46,7 @@ pub struct ClonedNode<T: Clone>(pub T);
impl<'i, T: Clone + 'i> Node<'i, ()> for ClonedNode<T> {
type Output = T;
fn eval<'s: 'i>(&'s self, _input: ()) -> Self::Output {
fn eval(&'i self, _input: ()) -> Self::Output {
self.0.clone()
}
}
@@ -69,7 +69,7 @@ pub struct DefaultNode<T>(PhantomData<T>);
impl<'i, T: Default + 'i> Node<'i, ()> for DefaultNode<T> {
type Output = T;
fn eval<'s: 'i>(&self, _input: ()) -> Self::Output {
fn eval(&'i self, _input: ()) -> Self::Output {
T::default()
}
}
@@ -87,7 +87,7 @@ pub struct ForgetNode;
impl<'i, T: 'i> Node<'i, T> for ForgetNode {
type Output = ();
fn eval<'s: 'i>(&self, _input: T) -> Self::Output {}
fn eval(&'i self, _input: T) -> Self::Output {}
}
impl ForgetNode {