Skip to content

Commit

Permalink
refactor!: Empirical::new -> Result<_, Infallible>
Browse files Browse the repository at this point in the history
No value of `Infallible` can ever exist, so it is statically
proven that `Result<Empirical, Infallible>` can never exist
as a `Result::Err` variant. This allows layout optimizations
and is arguably a clearer API.
  • Loading branch information
FreezyLemon authored and YeungOnion committed Dec 3, 2024
1 parent b73f189 commit 748aa55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/distribution/empirical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -83,8 +84,7 @@ impl Empirical {
/// let mut result = Empirical::new();
/// assert!(result.is_ok());
/// ```
#[allow(clippy::result_unit_err)]
pub fn new() -> Result<Empirical, ()> {
pub fn new() -> Result<Empirical, Infallible> {
Ok(Empirical {
data: BTreeMap::new(),
sum: 0,
Expand Down

0 comments on commit 748aa55

Please sign in to comment.