concision_core/activate/traits/
rho.rs1pub trait Rho<Rhs = Self> {
8 type Output;
9
10 fn rho(&self, rhs: Rhs) -> Self::Output;
11}
12
13pub trait RhoGradient<Rhs = Self>: Rho<Self::Input> {
14 type Input;
15 type Delta;
16
17 fn rho_gradient(&self, rhs: Rhs) -> Self::Delta;
18}
19
20#[cfg(feature = "alloc")]
24use alloc::boxed::Box;
25
26#[cfg(feature = "alloc")]
27impl<X, Y> Rho<X> for Box<dyn Rho<X, Output = Y>> {
28 type Output = Y;
29
30 fn rho(&self, rhs: X) -> Self::Output {
31 self.as_ref().rho(rhs)
32 }
33}
34
35impl<X, Y, F> Rho<X> for F
36where
37 F: Fn(X) -> Y,
38{
39 type Output = Y;
40
41 fn rho(&self, rhs: X) -> Self::Output {
42 self(rhs)
43 }
44}