diff --git a/uint/src/uint.rs b/uint/src/uint.rs index ac0ffc85e..493e2e21e 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -38,6 +38,23 @@ pub enum FromDecStrErr { InvalidLength, } +#[cfg(feature = "std")] +impl std::fmt::Display for FromDecStrErr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + FromDecStrErr::InvalidCharacter => "a character is not in the range 0-9", + FromDecStrErr::InvalidLength => "the number is too large for the type", + } + ) + } +} + +#[cfg(feature = "std")] +impl std::error::Error for FromDecStrErr {} + #[macro_export] #[doc(hidden)] macro_rules! impl_map_from {