reweb3_num/errors/
tryfrom.rs

1use core::fmt::{self, Display, Formatter};
2
3/// The error type that is returned when a failed conversion from an integer occurs.
4///
5/// This error will occur for example when using the [`TryFrom`](https://doc.rust-lang.org/core/convert/trait.TryFrom.html) trait to convert a negative [`i32`] to a [`BUint`](crate::BUint).
6#[derive(Debug, PartialEq, Eq, Copy, Clone)]
7pub struct TryFromIntError(pub(crate) ());
8
9const ERROR_MESSAGE: &str = concat!(
10    super::err_prefix!(),
11    "out of range integral type conversion attempted"
12);
13
14impl Display for TryFromIntError {
15    #[inline]
16    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
17        write!(f, "{}", ERROR_MESSAGE)
18    }
19}