Skip to content

Commit 4f32bcd

Browse files
committed
Fix clippy warnings
1 parent bcf1103 commit 4f32bcd

File tree

10 files changed

+20
-16
lines changed

10 files changed

+20
-16
lines changed

src/auth/authentication_scheme.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl FromStr for AuthenticationScheme {
5353
// NOTE(yosh): matching here is lowercase as specified by RFC2617#section-1.2
5454
// > [...] case-insensitive token to identify the authentication scheme [...]
5555
// https://tools.ietf.org/html/rfc2617#section-1.2
56+
#[allow(clippy::match_str_case_mismatch)]
5657
match s.to_lowercase().as_str() {
5758
"basic" => Ok(Self::Basic),
5859
"bearer" => Ok(Self::Bearer),

src/body.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl AsyncRead for Body {
571571
cx: &mut Context<'_>,
572572
buf: &mut [u8],
573573
) -> Poll<io::Result<usize>> {
574-
let mut buf = match self.length {
574+
let buf = match self.length {
575575
None => buf,
576576
Some(length) if length == self.bytes_read => return Poll::Ready(Ok(0)),
577577
Some(length) => {
@@ -582,7 +582,7 @@ impl AsyncRead for Body {
582582
}
583583
};
584584

585-
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, &mut buf))?;
585+
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, buf))?;
586586
self.bytes_read += bytes as u64;
587587
Poll::Ready(Ok(bytes))
588588
}
@@ -632,6 +632,7 @@ mod test {
632632
#[derive(Debug, Deserialize)]
633633
#[serde(crate = "serde_crate")]
634634
struct Foo {
635+
#[allow(dead_code)]
635636
inner: String,
636637
}
637638
let body = Body::empty();
@@ -644,6 +645,7 @@ mod test {
644645
#[derive(Debug, Deserialize)]
645646
#[serde(crate = "serde_crate")]
646647
struct Foo {
648+
#[allow(dead_code)]
647649
inner: String,
648650
}
649651
let body = Body::empty();

src/cache/cache_control/cache_directive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl CacheDirective {
8888
return Ok(None);
8989
}
9090

91-
s.to_lowercase();
91+
let s = s.to_lowercase();
9292
let mut parts = s.split('=');
9393
let next = parts.next().unwrap();
9494

src/cache/clear_site_data/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ impl Header for ClearSiteData {
220220
let mut output = String::new();
221221
for (n, etag) in self.entries.iter().enumerate() {
222222
match n {
223-
0 => write!(output, "{}", etag.to_string()).unwrap(),
224-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
223+
0 => write!(output, "{}", etag).unwrap(),
224+
_ => write!(output, ", {}", etag).unwrap(),
225225
};
226226
}
227227

src/conditional/if_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl Header for IfMatch {
111111
let mut output = String::new();
112112
for (n, etag) in self.entries.iter().enumerate() {
113113
match n {
114-
0 => write!(output, "{}", etag.to_string()).unwrap(),
115-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
114+
0 => write!(output, "{}", etag).unwrap(),
115+
_ => write!(output, ", {}", etag).unwrap(),
116116
};
117117
}
118118

src/conditional/if_none_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ impl Header for IfNoneMatch {
117117
let mut output = String::new();
118118
for (n, etag) in self.entries.iter().enumerate() {
119119
match n {
120-
0 => write!(output, "{}", etag.to_string()).unwrap(),
121-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
120+
0 => write!(output, "{}", etag).unwrap(),
121+
_ => write!(output, ", {}", etag).unwrap(),
122122
};
123123
}
124124

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Error {
159159

160160
/// Retrieves a reference to the type name of the error, if available.
161161
pub fn type_name(&self) -> Option<&str> {
162-
self.type_name.as_deref()
162+
self.type_name
163163
}
164164

165165
/// Converts anything which implements `Display` into an `http_types::Error`.

src/hyperium_http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl TryFrom<HeaderName> for http::header::HeaderName {
6868

6969
fn try_from(name: HeaderName) -> Result<Self, Self::Error> {
7070
let name = name.as_str().as_bytes();
71-
http::header::HeaderName::from_bytes(name).map_err(|e| Error::new_adhoc(e))
71+
http::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
7272
}
7373
}
7474

@@ -86,7 +86,7 @@ impl TryFrom<HeaderValue> for http::header::HeaderValue {
8686

8787
fn try_from(value: HeaderValue) -> Result<Self, Self::Error> {
8888
let value = value.as_str().as_bytes();
89-
http::header::HeaderValue::from_bytes(value).map_err(|e| Error::new_adhoc(e))
89+
http::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
9090
}
9191
}
9292

src/method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ impl FromStr for Method {
413413
type Err = crate::Error;
414414

415415
fn from_str(s: &str) -> Result<Self, Self::Err> {
416+
#[allow(clippy::match_str_case_mismatch)]
416417
match &*s.to_ascii_uppercase() {
417418
"ACL" => Ok(Self::Acl),
418419
"BASELINE-CONTROL" => Ok(Self::BaselineControl),

src/utils/date.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ impl From<SystemTime> for HttpDate {
218218
.expect("all times should be after the epoch");
219219
let secs_since_epoch = dur.as_secs();
220220

221-
if secs_since_epoch >= YEAR_9999_SECONDS {
222-
// year 9999
223-
panic!("date must be before year 9999");
224-
}
221+
assert!(
222+
secs_since_epoch < YEAR_9999_SECONDS,
223+
"date must be before year 9999"
224+
);
225225

226226
/* 2000-03-01 (mod 400 year, immediately after feb29 */
227227
const LEAPOCH: i64 = 11017;

0 commit comments

Comments
 (0)