Skip to content

Commit

Permalink
Custom Debug impl for io::Error
Browse files Browse the repository at this point in the history
Fixes #26408

Signed-off-by: Peter Atashian <retep998@gmail.com>
  • Loading branch information
retep998 committed Jun 19, 2015
1 parent ff8fee1 commit 9a6b611
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libstd/io/error.rs
Expand Up @@ -37,7 +37,6 @@ pub struct Error {
repr: Repr,
}

#[derive(Debug)]
enum Repr {
Os(i32),
Custom(Box<Custom>),
Expand Down Expand Up @@ -240,6 +239,17 @@ impl Error {
}
}

impl fmt::Debug for Repr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self {
&Repr::Os(ref code) =>
fmt.debug_struct("Os").field("code", code)
.field("message", &sys::os::error_string(*code)).finish(),
&Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
Expand Down

0 comments on commit 9a6b611

Please sign in to comment.