From 748aa55b623d8eafb8a7c6ca788b353c3b396366 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Mon, 11 Nov 2024 12:25:25 +0100 Subject: [PATCH] refactor!: Empirical::new -> Result<_, Infallible> No value of `Infallible` can ever exist, so it is statically proven that `Result` can never exist as a `Result::Err` variant. This allows layout optimizations and is arguably a clearer API. --- src/distribution/empirical.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/distribution/empirical.rs b/src/distribution/empirical.rs index a6522fd1..c1d8bc71 100644 --- a/src/distribution/empirical.rs +++ b/src/distribution/empirical.rs @@ -2,6 +2,7 @@ use crate::distribution::ContinuousCDF; use crate::statistics::*; use non_nan::NonNan; use std::collections::btree_map::{BTreeMap, Entry}; +use std::convert::Infallible; use std::ops::Bound; mod non_nan { @@ -83,8 +84,7 @@ impl Empirical { /// let mut result = Empirical::new(); /// assert!(result.is_ok()); /// ``` - #[allow(clippy::result_unit_err)] - pub fn new() -> Result { + pub fn new() -> Result { Ok(Empirical { data: BTreeMap::new(), sum: 0,