concision_core/activate/impls/
impl_activator.rs

1/*
2    appellation: activate <module>
3    authors: @FL03
4*/
5use crate::activate::Activator;
6
7impl<X, Y, F> Activator<X> for F
8where
9    F: Fn(X) -> Y,
10{
11    type Output = Y;
12
13    fn activate(&self, rhs: X) -> Self::Output {
14        self(rhs)
15    }
16}
17
18// impl<F, S, D, A, B> Activator<ArrayBase<S, D, A>> for F
19// where
20//     F: Activator<A, Output = B>,
21//     S: Data<Elem = A>,
22//     D: Dimension,
23// {
24//     type Output = Array<B, D>;
25
26//     fn activate(&self, rhs: ArrayBase<S, D, A>) -> Self::Output {
27//         rhs.mapv(|x| self.activate(x))
28//     }
29// }
30
31#[cfg(feature = "alloc")]
32impl<X, Y> Activator<X> for alloc::boxed::Box<dyn Activator<X, Output = Y>> {
33    type Output = Y;
34
35    fn activate(&self, rhs: X) -> Self::Output {
36        self.as_ref().activate(rhs)
37    }
38}