Small changes for new 2024 edition
This commit is contained in:
18
src/lib.rs
18
src/lib.rs
@@ -82,7 +82,7 @@ where
|
|||||||
pub fn key(&self, idx: Index) -> Option<&K> {
|
pub fn key(&self, idx: Index) -> Option<&K> {
|
||||||
self.0
|
self.0
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, &value)| value == idx)
|
.find(|&(_, value)| *value == idx)
|
||||||
.map(|(key, _)| key)
|
.map(|(key, _)| key)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,11 +115,7 @@ fn erfc(x: f64) -> f64 {
|
|||||||
|
|
||||||
let r = t * (-z * z - 1.26551223 + t * h).exp();
|
let r = t * (-z * z - 1.26551223 + t * h).exp();
|
||||||
|
|
||||||
if x >= 0.0 {
|
if x >= 0.0 { r } else { 2.0 - r }
|
||||||
r
|
|
||||||
} else {
|
|
||||||
2.0 - r
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn erfc_inv(mut y: f64) -> f64 {
|
fn erfc_inv(mut y: f64) -> f64 {
|
||||||
@@ -147,11 +143,7 @@ fn erfc_inv(mut y: f64) -> f64 {
|
|||||||
x += err / (FRAC_2_SQRT_PI * (-(x.powi(2))).exp() - x * err)
|
x += err / (FRAC_2_SQRT_PI * (-(x.powi(2))).exp() - x * err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if y < 1.0 {
|
if y < 1.0 { x } else { -x }
|
||||||
x
|
|
||||||
} else {
|
|
||||||
-x
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ppf(p: f64, mu: f64, sigma: f64) -> f64 {
|
fn ppf(p: f64, mu: f64, sigma: f64) -> f64 {
|
||||||
@@ -239,9 +231,9 @@ pub(crate) fn sort_time(xs: &[i64], reverse: bool) -> Vec<usize> {
|
|||||||
let mut x = xs.iter().enumerate().collect::<Vec<_>>();
|
let mut x = xs.iter().enumerate().collect::<Vec<_>>();
|
||||||
|
|
||||||
if reverse {
|
if reverse {
|
||||||
x.sort_by_key(|(_, &x)| Reverse(x));
|
x.sort_by_key(|&(_, x)| Reverse(x));
|
||||||
} else {
|
} else {
|
||||||
x.sort_by_key(|(_, &x)| x);
|
x.sort_by_key(|&(_, x)| x);
|
||||||
}
|
}
|
||||||
|
|
||||||
x.into_iter().map(|(i, _)| i).collect()
|
x.into_iter().map(|(i, _)| i).collect()
|
||||||
|
|||||||
Reference in New Issue
Block a user