Added Ratable implementation for &'a T and &'a mut T.
This commit is contained in:
@@ -41,7 +41,7 @@ impl Gaussian {
|
|||||||
|
|
||||||
pub fn mu(&self) -> f64 {
|
pub fn mu(&self) -> f64 {
|
||||||
if self.pi == 0.0 {
|
if self.pi == 0.0 {
|
||||||
return 0.0;
|
0.0
|
||||||
} else {
|
} else {
|
||||||
self.tau / self.pi
|
self.tau / self.pi
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/lib.rs
30
src/lib.rs
@@ -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 {
|
pub trait RateableMut {
|
||||||
fn mu_mut(&mut self) -> &mut f64;
|
fn mu_mut(&mut self) -> &mut f64;
|
||||||
fn sigma_mut(&mut self) -> &mut f64;
|
fn sigma_mut(&mut self) -> &mut f64;
|
||||||
|
|||||||
Reference in New Issue
Block a user