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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use core::fmt::{self, Display, Formatter};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct OutOfBoundsError;
impl Display for OutOfBoundsError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str("number out of bounds")
}
}
#[cfg(feature = "std")]
impl std::error::Error for OutOfBoundsError {}
#[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 {}
pub(crate) const fn panic_divide_by_0() -> ! {
panic!("divisor must not be 0")
}
#[cfg(feature = "rand")]
pub(crate) const fn panic_empty_range() -> ! {
panic!("empty range for random generation")
}
pub(crate) const fn panic_allocate_too_much() -> ! {
panic!("try to allocate too much memory")
}
pub(crate) const fn panic_out_of_memory() -> ! {
panic!("out of memory")
}
pub(crate) const fn panic_negative_ubig() -> ! {
panic!("UBig result must not be negative")
}
pub(crate) const fn panic_different_rings() -> ! {
panic!("Modulo values from different rings")
}
pub(crate) fn panic_invalid_radix(radix: u32) -> ! {
panic!("invalid radix: {}, only radix 2-36 are supported", radix);
}
pub(crate) fn panic_invalid_log_oprand() -> ! {
panic!("logarithm is not defined for 0, base 0 and base 1!");
}