Repository: statrs-dev/statrs (language: rust)

Issue:
Update the dependency on rand
There's a compatibility issue between the current version of `statrs`, which depends on `rand` 0.5 (so, up to 0.5.5), and the latest version of `rand` (0.6).

**Minimal example**

Using the `Cargo.toml` dependencies section
```toml
[dependencies]
statrs = "0.10.0"
rand = "0.6.3"
```
and trying to compile the `main.rs` file
```rust
use statrs::distribution::Normal;

use rand::Rng;
use rand::distributions::Distribution;

fn main() {
    let n = Normal::new(0., 0.).unwrap();
    let ref mut rng = rand::thread_rng();
    let v = n.sample(rng);
    println!("Value: {}", v);
}
```
will not work, and produce the trait-related error message
```
error[E0599]: no method named `sample` found for type `statrs::distribution::normal::Normal` in the current scope
 --> src\main.rs:9:15
  |
9 |     let v = n.sample(rng);
  |               ^^^^^^
  |
  = note: the method `sample` exists but the following trait bounds were not satisfied:
          `statrs::distribution::normal::Normal : rand::Rng`
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
1 | use rand::distributions::Distribution;
  |
```

I forked `statrs` and did a couple of commits to update the dependency. Patching the `Cargo.toml` in the above example with my fork seems to work. I'll make a pull request


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 20ba6ffa..dea682e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@
 
 #editor specific
 /.vscode/
+.idea/
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 7094ec3b..664e3c04 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,4 +17,4 @@ name = "statrs"
 path = "src/lib.rs"
 
 [dependencies]
-rand = "0.5"
+rand = "0.6.3"
diff --git a/src/distribution/multinomial.rs b/src/distribution/multinomial.rs
index 497ea2d0..b57c963a 100644
--- a/src/distribution/multinomial.rs
+++ b/src/distribution/multinomial.rs
@@ -249,11 +249,12 @@ impl<'a> CheckedDiscrete<&'a [u64], f64> for Multinomial {
             return Err(StatsError::ContainerExpectedSumVar("x", "n"));
         }
         let coeff = factorial::multinomial(self.n, x);
-        let val = coeff * self
-            .p
-            .iter()
-            .zip(x.iter())
-            .fold(1.0, |acc, (pi, xi)| acc * pi.powf(*xi as f64));
+        let val = coeff
+            * self
+                .p
+                .iter()
+                .zip(x.iter())
+                .fold(1.0, |acc, (pi, xi)| acc * pi.powf(*xi as f64));
         Ok(val)
     }
 
@@ -284,12 +285,13 @@ impl<'a> CheckedDiscrete<&'a [u64], f64> for Multinomial {
             return Err(StatsError::ContainerExpectedSumVar("x", "n"));
         }
         let coeff = factorial::multinomial(self.n, x).ln();
-        let val = coeff + self
-            .p
-            .iter()
-            .zip(x.iter())
-            .map(|(pi, xi)| *xi as f64 * pi.ln())
-            .fold(0.0, |acc, x| acc + x);
+        let val = coeff
+            + self
+                .p
+                .iter()
+                .zip(x.iter())
+                .map(|(pi, xi)| *xi as f64 * pi.ln())
+                .fold(0.0, |acc, x| acc + x);
         Ok(val)
     }
 }
diff --git a/src/distribution/uniform.rs b/src/distribution/uniform.rs
index c5732baf..33a385f7 100644
--- a/src/distribution/uniform.rs
+++ b/src/distribution/uniform.rs
@@ -435,7 +435,8 @@ mod test {
 
     #[test]
     fn test_samples_in_range() {
-        use rand::{StdRng, SeedableRng};
+        use rand::rngs::StdRng;
+        use rand::SeedableRng;
         use rand::distributions::Distribution;
 
         let seed = [
diff --git a/src/statistics/iter_statistics.rs b/src/statistics/iter_statistics.rs
index 106d8a8a..d5d86a9a 100644
--- a/src/statistics/iter_statistics.rs
+++ b/src/statistics/iter_statistics.rs
@@ -244,7 +244,8 @@ where
 #[cfg(test)]
 mod test {
     use std::f64::consts;
-    use rand::{SeedableRng, StdRng};
+    use rand::rngs::StdRng;
+    use rand::{SeedableRng};
     use rand::distributions::Distribution;
     use distribution::Normal;
     use statistics::Statistics;


Test patch:
diff --git a/src/testing/mod.rs b/src/testing/mod.rs
index cae6b2b0..6ca7cc51 100644
--- a/src/testing/mod.rs
+++ b/src/testing/mod.rs
@@ -16,7 +16,7 @@ pub fn load_data(path: &str) -> Vec<f64> {
     // if reading the data file fails, we want to panic immediately
 
     let path_prefix = "./data/".to_string();
-    let true_path = path_prefix + path.trim().trim_left_matches('/');
+    let true_path = path_prefix + path.trim().trim_start_matches('/');
 
     let f = File::open(true_path).unwrap();
     let mut reader = BufReader::new(f);