Don't force nodes to store references to other nodes

This commit is contained in:
Dennis
2022-06-05 15:25:07 +02:00
committed by Keavon Chambers
parent 4b8c0ec4e1
commit 09f550bcd4
12 changed files with 252 additions and 242 deletions

View File

@@ -1,18 +1,50 @@
#![no_std]
#![cfg_attr(target_arch = "spirv", feature(register_attr), register_attr(spirv))]
#[cfg(feature = "async")]
extern crate alloc;
#[cfg(feature = "async")]
use alloc::boxed::Box;
#[cfg(feature = "async")]
use async_trait::async_trait;
pub mod generic;
pub mod ops;
//pub mod structural;
pub mod value;
#[rustfmt::skip]
pub trait Node<'n> {
type Output: 'n; // TODO: replace with generic associated type
fn eval(&'n self) -> Self::Output;
}
impl<'n, N: Node<'n>> Node<'n> for &'n N {
type Output = N::Output;
fn eval(&'n self) -> Self::Output {
Node::eval(*self)
}
}
#[cfg(feature = "async")]
#[async_trait]
pub trait AsyncNode<'n> {
type Output: 'n; // TODO: replace with generic associated type
async fn eval(&'n self) -> Self::Output;
}
#[cfg(feature = "async")]
#[async_trait]
impl<'n, N: Node<'n> + Sync> AsyncNode<'n> for N {
type Output = N::Output;
async fn eval(&'n self) -> Self::Output {
Node::eval(self)
}
}
pub trait Cache {
fn clear(&mut self);
}