refactor(error): use matches! macro in Error::is_* methods (#2367)

This commit is contained in:
Pawan Singh Bisht
2020-12-22 01:55:47 +05:30
committed by GitHub
parent 1dd761c87d
commit 6c593c2925

View File

@@ -125,18 +125,12 @@ pub(crate) struct TimedOut;
impl Error { impl Error {
/// Returns true if this was an HTTP parse error. /// Returns true if this was an HTTP parse error.
pub fn is_parse(&self) -> bool { pub fn is_parse(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::Parse(_))
Kind::Parse(_) => true,
_ => false,
}
} }
/// Returns true if this error was caused by user code. /// Returns true if this error was caused by user code.
pub fn is_user(&self) -> bool { pub fn is_user(&self) -> bool {
match self.inner.kind { matches!(self.inner.kind, Kind::User(_))
Kind::User(_) => true,
_ => false,
}
} }
/// Returns true if this was about a `Request` that was canceled. /// Returns true if this was about a `Request` that was canceled.