refactor(error): turn Void from an empty enum to a struct

This commit is contained in:
Sean McArthur
2017-01-06 12:41:08 -08:00
parent ff84959f83
commit 0686c81c57

View File

@@ -55,11 +55,11 @@ pub enum Error {
} }
#[doc(hidden)] #[doc(hidden)]
pub enum Void {} pub struct Void(());
impl fmt::Debug for Void { impl fmt::Debug for Void {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
match *self {} unreachable!()
} }
} }
@@ -87,7 +87,7 @@ impl StdError for Error {
Uri(ref e) => e.description(), Uri(ref e) => e.description(),
Io(ref e) => e.description(), Io(ref e) => e.description(),
Utf8(ref e) => e.description(), Utf8(ref e) => e.description(),
Error::__Nonexhaustive(ref void) => match *void {} Error::__Nonexhaustive(..) => unreachable!(),
} }
} }
@@ -96,7 +96,7 @@ impl StdError for Error {
Io(ref error) => Some(error), Io(ref error) => Some(error),
Uri(ref error) => Some(error), Uri(ref error) => Some(error),
Utf8(ref error) => Some(error), Utf8(ref error) => Some(error),
Error::__Nonexhaustive(ref void) => match *void {}, Error::__Nonexhaustive(..) => unreachable!(),
_ => None, _ => None,
} }
} }