Skip to content

Commit 00a08eb

Browse files
Formatting, cargo clippy
Formatting, cargo clippy Fix single error from earlier commit
1 parent 0800716 commit 00a08eb

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

src/cache/cache_control/cache_directive.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@ impl CacheDirective {
4747
/// Check whether this directive is valid in an HTTP request.
4848
pub fn valid_in_req(&self) -> bool {
4949
use CacheDirective::*;
50-
matches!(self,
51-
MaxAge(_) | MaxStale(_) | MinFresh(_) | NoCache | NoStore | NoTransform
52-
| OnlyIfCached)
50+
matches!(
51+
self,
52+
MaxAge(_) | MaxStale(_) | MinFresh(_) | NoCache | NoStore | NoTransform | OnlyIfCached
53+
)
5354
}
5455

5556
/// Check whether this directive is valid in an HTTP response.
5657
pub fn valid_in_res(&self) -> bool {
5758
use CacheDirective::*;
58-
matches!(self,
59+
matches!(
60+
self,
5961
MustRevalidate
60-
| NoCache
61-
| NoStore
62-
| NoTransform
63-
| Public
64-
| Private
65-
| ProxyRevalidate
66-
| MaxAge(_)
67-
| SMaxAge(_)
68-
| StaleIfError(_)
69-
| StaleWhileRevalidate(_))
62+
| NoCache
63+
| NoStore
64+
| NoTransform
65+
| Public
66+
| Private
67+
| ProxyRevalidate
68+
| MaxAge(_)
69+
| SMaxAge(_)
70+
| StaleIfError(_)
71+
| StaleWhileRevalidate(_)
72+
)
7073
}
7174

7275
/// Create an instance from a string slice.

src/conditional/etag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl ETag {
117117

118118
if !s
119119
.bytes()
120-
.all(|c| c == 0x21 || (c >= 0x23 && c <= 0x7E) || c >= 0x80)
120+
.all(|c| c == 0x21 || (0x23..=0x7E).contains(&c) || c >= 0x80)
121121
{
122122
return Err(Error::from_str(
123123
StatusCode::BadRequest,

src/content/accept.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use crate::content::{ContentType, MediaTypeProposal};
44
use crate::headers::{HeaderName, HeaderValue, Headers, ToHeaderValues, ACCEPT};
5+
use crate::mime::Mime;
56
use crate::utils::sort_by_weight;
67
use crate::{Error, StatusCode};
7-
use crate::mime::Mime;
88

99
use std::fmt::{self, Debug, Write};
1010
use std::option;

src/headers/header_value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::convert::TryFrom;
22
use std::fmt::{self, Debug, Display};
33
use std::str::FromStr;
44

5-
use crate::headers::HeaderValues;
6-
use crate::Error;
75
use crate::cookies::Cookie;
6+
use crate::headers::HeaderValues;
87
use crate::mime::Mime;
8+
use crate::Error;
99

1010
/// A header value.
1111
#[derive(Clone, Eq, PartialEq, Hash)]

src/hyperium_http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is the compat file for the "hyperium/http" crate.
22

3-
use crate::headers::{HeaderName, HeaderValue};
4-
use crate::{Body, Headers, Method, Request, Response, StatusCode, Url, Version};
3+
use crate::headers::{HeaderName, HeaderValue, Headers};
4+
use crate::{Body, Method, Request, Response, StatusCode, Url, Version};
55
use std::convert::TryFrom;
66
use std::str::FromStr;
77

src/proxies/forwarded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ mod tests {
545545
assert_eq!(forwarded.forwarded_for(), vec!["client.com"]);
546546
assert_eq!(forwarded.host(), Some("host.com"));
547547
assert_eq!(forwarded.proto(), Some("https"));
548-
assert!(matches!(forwarded, Forwarded{..}));
548+
assert!(matches!(forwarded, Forwarded { .. }));
549549
Ok(())
550550
}
551551

@@ -644,7 +644,7 @@ mod tests {
644644
assert_eq!(forwarded.forwarded_for(), vec!["client"]);
645645
assert_eq!(forwarded.host(), Some("example.com"));
646646
assert_eq!(forwarded.proto(), Some("https"));
647-
assert!(matches!(forwarded, Forwarded{..}));
647+
assert!(matches!(forwarded, Forwarded { .. }));
648648
Ok(())
649649
}
650650

src/status_code.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl StatusCode {
434434
/// continuing process.
435435
pub fn is_informational(&self) -> bool {
436436
let num: u16 = self.clone().into();
437-
num >= 100 && num < 200
437+
(100..200).contains(&num)
438438
}
439439

440440
/// Returns `true` if the status code is the `2xx` range.
@@ -443,7 +443,7 @@ impl StatusCode {
443443
/// received, understood, and accepted.
444444
pub fn is_success(&self) -> bool {
445445
let num: u16 = self.clone().into();
446-
num >= 200 && num < 300
446+
(200..300).contains(&num)
447447
}
448448

449449
/// Returns `true` if the status code is the `3xx` range.
@@ -452,7 +452,7 @@ impl StatusCode {
452452
/// taken in order to complete the request.
453453
pub fn is_redirection(&self) -> bool {
454454
let num: u16 = self.clone().into();
455-
num >= 300 && num < 400
455+
(300..400).contains(&num)
456456
}
457457

458458
/// Returns `true` if the status code is the `4xx` range.
@@ -461,7 +461,7 @@ impl StatusCode {
461461
/// or cannot be fulfilled.
462462
pub fn is_client_error(&self) -> bool {
463463
let num: u16 = self.clone().into();
464-
num >= 400 && num < 500
464+
(400..500).contains(&num)
465465
}
466466

467467
/// Returns `true` if the status code is the `5xx` range.
@@ -470,7 +470,7 @@ impl StatusCode {
470470
/// apparently valid request.
471471
pub fn is_server_error(&self) -> bool {
472472
let num: u16 = self.clone().into();
473-
num >= 500 && num < 600
473+
(500..600).contains(&num)
474474
}
475475

476476
/// The canonical reason for a given status code

0 commit comments

Comments
 (0)