Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Error for FromDecStrErr #346

Merged
merged 2 commits into from
Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions uint/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ pub enum FromDecStrErr {
InvalidLength,
}

#[cfg(feature = "std")]
impl std::fmt::Display for FromDecStrErr {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CI failure is legit, we should hide this (and the one below) impl under cfg(feature = std)

macro_rules! impl_std_for_uint {

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 {
Expand Down