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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use core::fmt::{self, Display, Formatter};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ConversionError {
OutOfBounds,
LossOfPrecision,
}
impl Display for ConversionError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
ConversionError::OutOfBounds => f.write_str("number out of bounds"),
ConversionError::LossOfPrecision => f.write_str("number can't be converted losslessly"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ConversionError {}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ParseError {
NoDigits,
InvalidDigit,
UnsupportedRadix,
}
impl Display for ParseError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
ParseError::NoDigits => f.write_str("no digits"),
ParseError::InvalidDigit => f.write_str("invalid digit"),
ParseError::UnsupportedRadix => f.write_str("unsupported radix"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ParseError {}