Added Ratable implementation for &'a T and &'a mut T.

This commit is contained in:
2019-01-02 19:41:12 +01:00
parent 712bcd9f42
commit a2210055db
2 changed files with 31 additions and 1 deletions

View File

@@ -41,7 +41,7 @@ impl Gaussian {
pub fn mu(&self) -> f64 {
if self.pi == 0.0 {
return 0.0;
0.0
} else {
self.tau / self.pi
}

View File

@@ -45,6 +45,36 @@ pub trait Rateable {
}
}
impl<'a, T> Rateable for &'a T
where
T: Rateable,
{
#[inline]
fn mu(&self) -> f64 {
T::mu(self)
}
#[inline]
fn sigma(&self) -> f64 {
T::sigma(self)
}
}
impl<'a, T> Rateable for &'a mut T
where
T: Rateable,
{
#[inline]
fn mu(&self) -> f64 {
T::mu(self)
}
#[inline]
fn sigma(&self) -> f64 {
T::sigma(self)
}
}
pub trait RateableMut {
fn mu_mut(&mut self) -> &mut f64;
fn sigma_mut(&mut self) -> &mut f64;