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
#[derive(Debug)]
pub struct IntegerDeltaError(pub(crate) IntegerDeltaErrorImpl);
#[derive(Debug)]
pub(crate) enum IntegerDeltaErrorImpl {
Conversion(isize),
Sub(usize, usize),
#[cfg(feature = "nightly")]
InvalidNonZero
}
#[cfg(not(feature = "no_std"))]
impl std::error::Error for IntegerDeltaError {}
mod fmt {
use super::*;
use std::fmt;
impl fmt::Display for IntegerDeltaError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
IntegerDeltaErrorImpl::Conversion(del) => write!(
f,
"Offset could not be stored (offset of {} is too large)",
del
),
IntegerDeltaErrorImpl::Sub(a, b) => {
write!(f, "Difference is beween {} and {} overflows `isize`", a, b)
},
#[cfg(feature = "nightly")]
IntegerDeltaErrorImpl::InvalidNonZero => {
write!(f, "Difference was zero when a `NonZero*` type was specified")
}
}
}
}
}