deep_causality_rand/errors/
uniform_error.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5use core::fmt;
6use std::error::Error;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum UniformDistributionError {
10    /// Input or range `high - low` is non-finite. Not relevant to integer types.
11    NonFinite,
12    /// Invalid range: low must be less than high
13    InvalidRange,
14    /// Empty range in uniform distribution
15    EmptyRange,
16}
17
18impl Error for UniformDistributionError {}
19
20impl fmt::Display for UniformDistributionError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        f.write_str(match self {
23            UniformDistributionError::NonFinite => "Non-finite range in uniform distribution",
24            UniformDistributionError::InvalidRange => "Invalid range: low must be less than high",
25            UniformDistributionError::EmptyRange => "Empty range in uniform distribution",
26        })
27    }
28}