From 24140422690f9296fda2cd2007345ac2f942d12e Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 9 Mar 2021 00:02:45 +0100 Subject: [PATCH] replace match ... { } with matches! macro where possible (#1208) --- src/error.rs | 30 ++++++------------------------ src/redirect.rs | 5 +---- 2 files changed, 7 insertions(+), 28 deletions(-) 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)) } }