replace match ... { } with matches! macro where possible (#1208)

This commit is contained in:
Enno Boland
2021-03-09 00:02:45 +01:00
committed by GitHub
parent a856638316
commit 2414042269
2 changed files with 7 additions and 28 deletions

View File

@@ -58,26 +58,17 @@ impl Error {
/// Returns true if the error is from a type Builder. /// Returns true if the error is from a type Builder.
pub fn is_builder(&self) -> bool { pub fn is_builder(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Builder)
Kind::Builder => true,
_ => false,
}
} }
/// Returns true if the error is from a `RedirectPolicy`. /// Returns true if the error is from a `RedirectPolicy`.
pub fn is_redirect(&self) -> bool { pub fn is_redirect(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Redirect)
Kind::Redirect => true,
_ => false,
}
} }
/// Returns true if the error is from `Response::error_for_status`. /// Returns true if the error is from `Response::error_for_status`.
pub fn is_status(&self) -> bool { pub fn is_status(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Status(_))
Kind::Status(_) => true,
_ => false,
}
} }
/// Returns true if the error is related to a timeout. /// Returns true if the error is related to a timeout.
@@ -96,10 +87,7 @@ impl Error {
/// Returns true if the error is related to the request /// Returns true if the error is related to the request
pub fn is_request(&self) -> bool { pub fn is_request(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Request)
Kind::Request => true,
_ => false,
}
} }
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
@@ -122,18 +110,12 @@ impl Error {
/// Returns true if the error is related to the request or response body /// Returns true if the error is related to the request or response body
pub fn is_body(&self) -> bool { pub fn is_body(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Body)
Kind::Body => true,
_ => false,
}
} }
/// Returns true if the error is related to decoding the response's body /// Returns true if the error is related to decoding the response's body
pub fn is_decode(&self) -> bool { pub fn is_decode(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Decode)
Kind::Decode => true,
_ => false,
}
} }
/// Returns the status code, if the error was generated from a response. /// Returns the status code, if the error was generated from a response.

View File

@@ -148,10 +148,7 @@ impl Policy {
} }
pub(crate) fn is_default(&self) -> bool { pub(crate) fn is_default(&self) -> bool {
match self.inner { matches!(self.inner, PolicyKind::Limit(10))
PolicyKind::Limit(10) => true,
_ => false,
}
} }
} }