|
|
@@ -62,11 +62,11 @@ macro_rules! simple_enum_error {
|
|
|
__FutureProof,
|
|
|
}
|
|
|
|
|
|
- impl Error for ParseError {
|
|
|
- fn description(&self) -> &str {
|
|
|
+ impl fmt::Display for ParseError {
|
|
|
+ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
|
|
match *self {
|
|
|
$(
|
|
|
- ParseError::$name => $description,
|
|
|
+ ParseError::$name => fmt.write_str($description),
|
|
|
)+
|
|
|
ParseError::__FutureProof => {
|
|
|
unreachable!("Don't abuse the FutureProof!");
|
|
|
@@ -77,6 +77,8 @@ macro_rules! simple_enum_error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl Error for ParseError {}
|
|
|
+
|
|
|
simple_enum_error! {
|
|
|
EmptyHost => "empty host",
|
|
|
IdnaError => "invalid international domain name",
|
|
|
@@ -90,12 +92,6 @@ simple_enum_error! {
|
|
|
Overflow => "URLs more than 4 GB are not supported",
|
|
|
}
|
|
|
|
|
|
-impl fmt::Display for ParseError {
|
|
|
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
- fmt::Display::fmt(self.description(), f)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
impl From<::idna::Errors> for ParseError {
|
|
|
fn from(_: ::idna::Errors) -> ParseError {
|
|
|
ParseError::IdnaError
|