1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::num::TryFromIntError;

#[derive(Clone, Debug, PartialEq)]
pub enum ConversionError {
    NoData,
    InvalidChar(char),
    NotInRange { permitted: String, error: String },

    UnexpectedEnd,

    /// f32::INFINITY, f64::INFINITY
    Infinity,

    /// f32::NEG_INFINITY, f64::NEG_INFINITY
    NegInfinity,

    /// f32::NAN, f64::NAN
    NotANumber,

    /// `std::num::TryFromIntError` is always converted to `ConversionError::TryFromIntError`.
    /// For example, if you try to convert a `BigInt` into a `u32`, it's first converted to `i64`, then to `u32`.
    /// If the latter one fails, Rust emits `std::num::TryFromIntError`, which hmath cannot understand.
    /// In this case hmath will throw this error.
    TryFromIntError
}

impl From<TryFromIntError> for ConversionError {

    fn from(_: TryFromIntError) -> Self {
        ConversionError::TryFromIntError
    }

}