1#[derive(Debug)]
5pub struct IntegerOffsetError(pub(crate) IntegerOffsetErrorImpl);
6
7#[derive(Debug)]
10pub(crate) enum IntegerOffsetErrorImpl {
11 Conversion(isize),
13 Sub(usize, usize),
15}
16
17#[cfg(feature = "std")]
18impl std::error::Error for IntegerOffsetError {}
19
20mod fmt {
21 use super::*;
22 use std::fmt;
23
24 impl fmt::Display for IntegerOffsetError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 match self.0 {
27 IntegerOffsetErrorImpl::Conversion(del) => write!(
28 f,
29 "Offset could not be stored (offset of {} is too large)",
30 del
31 ),
32 IntegerOffsetErrorImpl::Sub(a, b) => {
33 write!(f, "Difference is beween {} and {} overflows `isize`", a, b)
34 }
35 }
36 }
37 }
38}