Bump dyn-any version + format code

This commit is contained in:
Dennis
2022-08-04 09:08:48 +02:00
parent 30af1ba8db
commit 5e9545322e
12 changed files with 464 additions and 513 deletions

View File

@@ -14,62 +14,62 @@ pub mod ops;
pub mod value;
pub trait Node<'n> {
type Output; // TODO: replace with generic associated type
type Output; // TODO: replace with generic associated type
fn eval(&'n self) -> Self::Output;
fn eval(&'n self) -> Self::Output;
}
impl<'n, N: Node<'n>> Node<'n> for &'n N {
type Output = N::Output;
type Output = N::Output;
fn eval(&'n self) -> Self::Output {
Node::eval(*self)
}
fn eval(&'n self) -> Self::Output {
Node::eval(*self)
}
}
pub trait NodeInput {
type Nodes;
type Nodes;
fn new(input: Self::Nodes) -> Self;
fn new(input: Self::Nodes) -> Self;
}
trait FQN {
fn fqn(&self) -> &'static str;
fn fqn(&self) -> &'static str;
}
trait Input<I> {
unsafe fn input(&self, input: I);
unsafe fn input(&self, input: I);
}
#[cfg(feature = "async")]
#[async_trait]
pub trait AsyncNode<'n> {
type Output; // TODO: replace with generic associated type
type Output; // TODO: replace with generic associated type
async fn eval_async(&'n self) -> Self::Output;
async fn eval_async(&'n self) -> Self::Output;
}
#[cfg(feature = "async")]
#[async_trait]
impl<'n, N: Node<'n> + Sync> AsyncNode<'n> for N {
type Output = N::Output;
type Output = N::Output;
async fn eval_async(&'n self) -> Self::Output {
Node::eval(self)
}
async fn eval_async(&'n self) -> Self::Output {
Node::eval(self)
}
}
pub trait Cache {
fn clear(&mut self);
fn clear(&mut self);
}
#[cfg(not(feature = "gpu"))]
extern crate alloc;
#[cfg(not(feature = "gpu"))]
impl<'n, I, O: 'n> Node<'n, I> for alloc::boxed::Box<dyn Node<'n, I, Output = O>> {
type Output = O;
type Output = O;
fn eval(&'n self, input: &'n I) -> Self::Output {
self.as_ref().eval(input)
}
fn eval(&'n self, input: &'n I) -> Self::Output {
self.as_ref().eval(input)
}
}