From 07485798032bf4703e405a1d756435b4135b63f9 Mon Sep 17 00:00:00 2001 From: zawz <34189424+zawwz@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:37:18 +0100 Subject: Fix clippy warnings in components/shared/net/request.rs (#31551) * Fix clippy warnings in components/shared/net/request.rs Signed-off-by: mateoferon * fixup! Fix clippy warnings in components/shared/net/request.rs --------- Signed-off-by: mateoferon --- components/shared/net/request.rs | 67 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'components/shared/net/request.rs') diff --git a/components/shared/net/request.rs b/components/shared/net/request.rs index 1f9f0abf986..b1aa5fd0f04 100644 --- a/components/shared/net/request.rs +++ b/components/shared/net/request.rs @@ -208,7 +208,7 @@ impl RequestBody { } pub fn len(&self) -> Option { - self.total_bytes.clone() + self.total_bytes } } @@ -567,19 +567,19 @@ impl Request { /// pub fn is_subresource_request(&self) -> bool { - match self.destination { + matches!( + self.destination, Destination::Audio | - Destination::Font | - Destination::Image | - Destination::Manifest | - Destination::Script | - Destination::Style | - Destination::Track | - Destination::Video | - Destination::Xslt | - Destination::None => true, - _ => false, - } + Destination::Font | + Destination::Image | + Destination::Manifest | + Destination::Script | + Destination::Style | + Destination::Track | + Destination::Video | + Destination::Xslt | + Destination::None + ) } pub fn timing_type(&self) -> ResourceTimingType { @@ -605,7 +605,7 @@ impl Referrer { // TODO: values in the control-code range are being quietly stripped out by // HeaderMap and never reach this function to be loudly rejected! fn is_cors_unsafe_request_header_byte(value: &u8) -> bool { - match value { + matches!(value, 0x00..=0x08 | 0x10..=0x19 | 0x22 | @@ -621,9 +621,8 @@ fn is_cors_unsafe_request_header_byte(value: &u8) -> bool { 0x5D | 0x7B | 0x7D | - 0x7F => true, - _ => false, - } + 0x7F + ) } // https://fetch.spec.whatwg.org/#cors-safelisted-request-header @@ -635,18 +634,19 @@ fn is_cors_safelisted_request_accept(value: &[u8]) -> bool { // https://fetch.spec.whatwg.org/#cors-safelisted-request-header // subclauses `accept-language`, `content-language` fn is_cors_safelisted_language(value: &[u8]) -> bool { - value.iter().all(|&x| match x { - 0x30..=0x39 | - 0x41..=0x5A | - 0x61..=0x7A | - 0x20 | - 0x2A | - 0x2C | - 0x2D | - 0x2E | - 0x3B | - 0x3D => true, - _ => false, + value.iter().all(|&x| { + matches!(x, + 0x30..=0x39 | + 0x41..=0x5A | + 0x61..=0x7A | + 0x20 | + 0x2A | + 0x2C | + 0x2D | + 0x2E | + 0x3B | + 0x3D + ) }) } @@ -697,10 +697,7 @@ pub fn is_cors_safelisted_request_header, V: AsRef<[u8]>>( /// pub fn is_cors_safelisted_method(m: &Method) -> bool { - match *m { - Method::GET | Method::HEAD | Method::POST => true, - _ => false, - } + matches!(*m, Method::GET | Method::HEAD | Method::POST) } /// @@ -733,7 +730,7 @@ pub fn get_cors_unsafe_header_names(headers: &HeaderMap) -> Vec { } // Step 6 - return convert_header_names_to_sorted_lowercase_set(unsafe_names); + convert_header_names_to_sorted_lowercase_set(unsafe_names) } /// @@ -745,5 +742,5 @@ pub fn convert_header_names_to_sorted_lowercase_set( let mut ordered_set = header_names.to_vec(); ordered_set.sort_by(|a, b| a.as_str().partial_cmp(b.as_str()).unwrap()); ordered_set.dedup(); - return ordered_set.into_iter().cloned().collect(); + ordered_set.into_iter().cloned().collect() } -- cgit v1.2.3