mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
Don't force nodes to store references to other nodes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user