mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
* gcore: replace `core` and `alloc` paths with `std` * node-graph: remove unnecessary path prefix * gcore: remove most `#[cfg(target_arch = "spirv")]`, keep some potentially useful ones --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
18 lines
395 B
Rust
18 lines
395 B
Rust
use crate::Node;
|
|
use std::marker::PhantomData;
|
|
#[derive(Clone)]
|
|
pub struct FnNode<T: Fn(I) -> O, I, O>(T, PhantomData<(I, O)>);
|
|
|
|
impl<'i, T: Fn(I) -> O + 'i, O: 'i, I: 'i> Node<'i, I> for FnNode<T, I, O> {
|
|
type Output = O;
|
|
fn eval(&'i self, input: I) -> Self::Output {
|
|
self.0(input)
|
|
}
|
|
}
|
|
|
|
impl<T: Fn(I) -> O, I, O> FnNode<T, I, O> {
|
|
pub fn new(f: T) -> Self {
|
|
FnNode(f, PhantomData)
|
|
}
|
|
}
|