Rustify some code.

This commit is contained in:
2018-10-24 20:15:29 +02:00
parent 77523e9db4
commit bcdabf9fbb
3 changed files with 85 additions and 118 deletions

View File

@@ -295,8 +295,6 @@ where
#[cfg(test)]
mod tests {
use std::f64;
use approx::{AbsDiffEq, RelativeEq};
use super::*;
@@ -306,12 +304,10 @@ mod tests {
impl AbsDiffEq for Rating {
type Epsilon = f64;
#[inline]
fn default_epsilon() -> Self::Epsilon {
f64::default_epsilon()
}
#[inline]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.mu.abs_diff_eq(&other.mu, epsilon) && self.sigma.abs_diff_eq(&other.sigma, epsilon)
}
@@ -338,7 +334,11 @@ mod tests {
let alice = Rating::new(MU, SIGMA);
let bob = Rating::new(MU, SIGMA);
assert_relative_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579, epsilon = EPSILON);
assert_relative_eq!(
quality(&[&[alice], &[bob]]),
0.4472135954999579,
epsilon = EPSILON
);
}
#[test]