mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Add Exec trait to simplify calling nodes without input data
This commit is contained in:
parent
ab67953f96
commit
f8d4e10f35
1 changed files with 11 additions and 1 deletions
|
@ -53,6 +53,16 @@ pub trait After: Sized {
|
|||
}
|
||||
impl<Second: Node> After for Second {}
|
||||
|
||||
pub trait Exec: Node
|
||||
where
|
||||
for<'a> &'a (): Borrow<<Self as Node>::Input<'a>>,
|
||||
{
|
||||
fn exec(&self) -> Self::Output<'_> {
|
||||
self.eval(&())
|
||||
}
|
||||
}
|
||||
impl<T: Node> Exec for T where for<'a> &'a (): Borrow<<T as Node>::Input<'a>> {}
|
||||
|
||||
pub trait DynamicInput {
|
||||
fn set_kwarg_by_name(&mut self, name: &str, value: &dyn Any);
|
||||
fn set_arg_by_index(&mut self, index: usize, value: &dyn Any);
|
||||
|
@ -60,7 +70,7 @@ pub trait DynamicInput {
|
|||
|
||||
fn main() {
|
||||
let int = IntNode::<32>;
|
||||
let add: u32 = AddNode::<u32>::default().eval((int.eval(&()), int.eval(&())));
|
||||
let add: u32 = AddNode::<u32>::default().eval((int.exec(), int.exec()));
|
||||
let fnode = FnNode::new(|(a, b): &(i32, i32)| a - b);
|
||||
//let sub = fnode.any(&("a", 2));
|
||||
let cache = CacheNode::new(&fnode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue