Skip to content

Commit

Permalink
clippy::len_without_is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
eopb committed May 21, 2020
1 parent 719cc3b commit 40a353a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ impl<State> Request<State> {
pub fn len(&self) -> Option<usize> {
self.request.len()
}
/// Checks if the body is empty.
#[must_use]
pub fn is_empty(&self) -> Option<bool> {
Some(self.request.len()? == 0)
}
}

impl<State> AsMut<http::Request> for Request<State> {
Expand Down
6 changes: 6 additions & 0 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ impl Response {
self.res.len()
}

/// Checks if the body is empty.
#[must_use]
pub fn is_empty(&self) -> Option<bool> {
Some(self.res.len()? == 0)
}

/// Get an HTTP header.
#[must_use]
pub fn header(&self, name: &HeaderName) -> Option<&Vec<HeaderValue>> {
Expand Down

0 comments on commit 40a353a

Please sign in to comment.