concision_core/traits/
activate.rs

1pub trait BinaryAction<A, B = A> {
2    type Output;
3
4    fn activate(lhs: A, rhs: B) -> Self::Output;
5}
6
7pub trait Activate<Rhs = Self> {
8    type Output;
9
10    fn activate(&self, rhs: Rhs) -> Self::Output;
11}
12
13pub trait ActivateGradient<Rhs = Self>: Activate<Self::Input> {
14    type Input;
15    type Delta;
16
17    fn activate_gradient(&self, rhs: Rhs) -> Self::Delta;
18}
19
20impl<X, Y> Activate<X> for Box<dyn Activate<X, Output = Y>> {
21    type Output = Y;
22
23    fn activate(&self, rhs: X) -> Self::Output {
24        self.as_ref().activate(rhs)
25    }
26}
27
28impl<X, Y, F> Activate<X> for F
29where
30    F: Fn(X) -> Y,
31{
32    type Output = Y;
33
34    fn activate(&self, rhs: X) -> Self::Output {
35        self(rhs)
36    }
37}