diff --git a/src/error.rs b/src/error.rs index cb05eb7..fb73de9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -58,26 +58,17 @@ impl Error { /// Returns true if the error is from a type Builder. pub fn is_builder(&self) -> bool { - match self.inner.kind { - Kind::Builder => true, - _ => false, - } + matches!(self.inner.kind, Kind::Builder) } /// Returns true if the error is from a `RedirectPolicy`. pub fn is_redirect(&self) -> bool { - match self.inner.kind { - Kind::Redirect => true, - _ => false, - } + matches!(self.inner.kind, Kind::Redirect) } /// Returns true if the error is from `Response::error_for_status`. pub fn is_status(&self) -> bool { - match self.inner.kind { - Kind::Status(_) => true, - _ => false, - } + matches!(self.inner.kind, Kind::Status(_)) } /// 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 pub fn is_request(&self) -> bool { - match self.inner.kind { - Kind::Request => true, - _ => false, - } + matches!(self.inner.kind, Kind::Request) } #[cfg(not(target_arch = "wasm32"))] @@ -122,18 +110,12 @@ impl Error { /// Returns true if the error is related to the request or response body pub fn is_body(&self) -> bool { - match self.inner.kind { - Kind::Body => true, - _ => false, - } + matches!(self.inner.kind, Kind::Body) } /// Returns true if the error is related to decoding the response's body pub fn is_decode(&self) -> bool { - match self.inner.kind { - Kind::Decode => true, - _ => false, - } + matches!(self.inner.kind, Kind::Decode) } /// Returns the status code, if the error was generated from a response. diff --git a/src/redirect.rs b/src/redirect.rs index a0722a6..00faf6e 100644 --- a/src/redirect.rs +++ b/src/redirect.rs @@ -148,10 +148,7 @@ impl Policy { } pub(crate) fn is_default(&self) -> bool { - match self.inner { - PolicyKind::Limit(10) => true, - _ => false, - } + matches!(self.inner, PolicyKind::Limit(10)) } }