From 40a353ad130dbbf8afeab4d734dfd828aac2edd8 Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Thu, 21 May 2020 20:33:31 +0100 Subject: [PATCH] clippy::len_without_is_empty --- src/request.rs | 5 +++++ src/response.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/request.rs b/src/request.rs index 6e801f5cb..e47a744ed 100644 --- a/src/request.rs +++ b/src/request.rs @@ -313,6 +313,11 @@ impl Request { pub fn len(&self) -> Option { self.request.len() } + /// Checks if the body is empty. + #[must_use] + pub fn is_empty(&self) -> Option { + Some(self.request.len()? == 0) + } } impl AsMut for Request { diff --git a/src/response.rs b/src/response.rs index e06242af3..aeb5185ae 100644 --- a/src/response.rs +++ b/src/response.rs @@ -91,6 +91,12 @@ impl Response { self.res.len() } + /// Checks if the body is empty. + #[must_use] + pub fn is_empty(&self) -> Option { + Some(self.res.len()? == 0) + } + /// Get an HTTP header. #[must_use] pub fn header(&self, name: &HeaderName) -> Option<&Vec> {