diff --git a/optimal-compute-core/src/lib.rs b/optimal-compute-core/src/lib.rs index f8a9a06..15acc7a 100644 --- a/optimal-compute-core/src/lib.rs +++ b/optimal-compute-core/src/lib.rs @@ -370,14 +370,20 @@ pub trait ComputationFn: Computation { } #[derive(Clone, Copy, Debug)] -pub struct Val { +pub struct Val +where + Self: Computation, +{ dim: PhantomData, - inner: A, + pub inner: A, } #[derive(Clone, Copy, Debug)] -pub struct Arg { - name: &'static str, +pub struct Arg +where + Self: Computation, +{ + pub name: &'static str, dim: PhantomData, elem: PhantomData, } @@ -389,17 +395,16 @@ pub type Arg0 = Arg; pub type Arg1 = Arg; pub type Arg2 = Arg; -impl Val { +impl Val +where + Self: Computation, +{ pub fn new(value: A) -> Self { Val { dim: PhantomData, inner: value, } } - - pub fn into_inner(self) -> A { - self.inner - } } impl Arg { @@ -510,6 +515,7 @@ where impl fmt::Display for Val, A> where + Self: Computation, A: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -517,7 +523,10 @@ where } } -impl fmt::Display for Arg { +impl fmt::Display for Arg +where + Self: Computation, +{ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.name) } diff --git a/optimal-compute-core/src/run/run_core.rs b/optimal-compute-core/src/run/run_core.rs index 640b608..c9b677a 100644 --- a/optimal-compute-core/src/run/run_core.rs +++ b/optimal-compute-core/src/run/run_core.rs @@ -29,7 +29,10 @@ pub trait RunCore { fn run_core(self, args: ArgVals) -> Self::Output; } -impl RunCore for Val { +impl RunCore for Val +where + Self: Computation, +{ type Output = Value; fn run_core(self, _args: ArgVals) -> Self::Output { @@ -39,6 +42,7 @@ impl RunCore for Val { impl RunCore for Arg where + Self: Computation, A: 'static + ArgVal, { type Output = Value;