Skip to content

Commit

Permalink
replace match ... { } with matches! macro where possible (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox authored Mar 8, 2021
1 parent a856638 commit 2414042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
30 changes: 6 additions & 24 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"))]
Expand All @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions src/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 2414042

Please sign in to comment.