1#[cfg(feature = "alloc")]
8use alloc::string::String;
9use rand_distr::NormalError;
10use rand_distr::uniform::Error as UniformError;
11#[allow(dead_code)]
12pub(crate) type Result<T> = core::result::Result<T, InitError>;
15
16#[derive(Debug, thiserror::Error)]
17pub enum InitError {
18 #[cfg(feature = "alloc")]
19 #[error("Failed to initialize with the given distribution: {0}")]
20 DistributionError(String),
21 #[cfg(feature = "rand")]
22 #[error("[NormalError] {0}")]
23 NormalError(NormalError),
24 #[error(transparent)]
25 #[cfg(feature = "rand")]
26 UniformError(#[from] UniformError),
27}
28
29#[cfg(feature = "rand")]
30impl From<NormalError> for InitError {
31 fn from(err: NormalError) -> Self {
32 InitError::NormalError(err)
33 }
34}