mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Implement borrow stack for node graph
This commit is contained in:
@@ -12,4 +12,4 @@ authors = ["Dennis Kobert <dennis@kobert.dev>"]
|
||||
#default = ["std"]
|
||||
|
||||
[dependencies]
|
||||
#dyn-any = {path = "../dyn-any", features = ["derive"], optional = true}
|
||||
dyn-any = {path = "../dyn-any", features = ["derive"]}
|
||||
|
||||
@@ -22,3 +22,12 @@ impl<'n, T: Node<'n, ()>> Exec<'n> for T {}
|
||||
pub trait Cache {
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
extern crate alloc;
|
||||
impl<'n, I, O: 'n> Node<'n, I> for alloc::boxed::Box<dyn Node<'n, I, Output = O>> {
|
||||
type Output = O;
|
||||
|
||||
fn eval(&'n self, input: &'n I) -> Self::Output {
|
||||
self.as_ref().eval(input)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ impl<'n, const N: u32> Node<'n, ()> for IntNode<N> {
|
||||
}
|
||||
}
|
||||
|
||||
use dyn_any::{DynAny, StaticType, StaticTypeSized};
|
||||
#[derive(Default)]
|
||||
pub struct ValueNode<'n, T>(T, PhantomData<&'n ()>);
|
||||
impl<'n, T: 'n> Node<'n, ()> for ValueNode<'n, T> {
|
||||
@@ -18,6 +19,11 @@ impl<'n, T: 'n> Node<'n, ()> for ValueNode<'n, T> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'n, T: StaticTypeSized> StaticType for ValueNode<'n, T> {
|
||||
type Static = ValueNode<'static, <T as StaticTypeSized>::Static>;
|
||||
}
|
||||
|
||||
impl<'n, T> ValueNode<'n, T> {
|
||||
pub const fn new(value: T) -> ValueNode<'n, T> {
|
||||
ValueNode(value, PhantomData)
|
||||
|
||||
Reference in New Issue
Block a user