From cff9aad37758116e068be4a0aeb9d867c591ad44 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Tue, 10 Sep 2024 14:34:17 +0200 Subject: [PATCH 1/2] refactor: reduce MSRV to 1.61 --- Cargo.lock.MSRV | 28 ++++++++++++++-------------- Cargo.toml | 2 +- src/distribution/empirical.rs | 13 ++++++------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Cargo.lock.MSRV b/Cargo.lock.MSRV index 3dcbc271..4958be1d 100644 --- a/Cargo.lock.MSRV +++ b/Cargo.lock.MSRV @@ -25,9 +25,9 @@ checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "approx" @@ -52,9 +52,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -382,9 +382,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -395,15 +395,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -556,18 +556,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 6c80cc70..8625bd99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" include = ["CHANGELOG.md", "LICENSE.md", "src/", "tests/"] # When changing MSRV: Also update the README -rust-version = "1.66.0" +rust-version = "1.61.0" [lib] name = "statrs" diff --git a/src/distribution/empirical.rs b/src/distribution/empirical.rs index 965d8c7f..b3a70d21 100644 --- a/src/distribution/empirical.rs +++ b/src/distribution/empirical.rs @@ -153,18 +153,17 @@ impl Empirical { impl std::fmt::Display for Empirical { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if let Some((&NonNan(x), _)) = self.data.first_key_value() { + let mut enumerated_values = self + .data + .iter() + .flat_map(|(&NonNan(x), &count)| std::iter::repeat(x).take(count as usize)); + + if let Some(x) = enumerated_values.next() { write!(f, "Empirical([{:.3e}", x)?; } else { return write!(f, "Empirical(∅)"); } - let mut enumerated_values = self - .data - .iter() - .flat_map(|(&NonNan(x), &count)| std::iter::repeat(x).take(count as usize)) - .skip(1); - for val in enumerated_values.by_ref().take(4) { write!(f, ", {:.3e}", val)?; } From 567a77d26f682c03ce9f968f86f61937c1d7140d Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Tue, 10 Sep 2024 15:16:11 +0200 Subject: [PATCH 2/2] doc: reflect MSRV change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 973f0046..b1ac1396 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you'd like to modify where the data is downloaded, you can use the environmen ## Minimum supported Rust version (MSRV) -This crate requires a Rust version of 1.66.0 or higher. Increases in MSRV will be considered a semver non-breaking API change and require a version increase (PATCH until 1.0.0, MINOR after 1.0.0). +This crate requires a Rust version of 1.61.0 or higher. Increases in MSRV will be considered a semver non-breaking API change and require a version increase (PATCH until 1.0.0, MINOR after 1.0.0). ## Contributing