Skip to content

Commit 7236637

Browse files
authored
Merge pull request #399 from arlyon/v2.x.x-backports
Fix all failing clippy lints for backports branch
2 parents 6f38b3e + 72f421d commit 7236637

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

src/body.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl AsyncRead for Body {
507507
cx: &mut Context<'_>,
508508
buf: &mut [u8],
509509
) -> Poll<io::Result<usize>> {
510-
let mut buf = match self.length {
510+
let buf = match self.length {
511511
None => buf,
512512
Some(length) if length == self.bytes_read => return Poll::Ready(Ok(0)),
513513
Some(length) => {
@@ -516,7 +516,7 @@ impl AsyncRead for Body {
516516
}
517517
};
518518

519-
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, &mut buf))?;
519+
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, buf))?;
520520
self.bytes_read += bytes;
521521
Poll::Ready(Ok(bytes))
522522
}
@@ -551,7 +551,7 @@ async fn peek_mime(file: &mut async_std::fs::File) -> io::Result<Option<Mime>> {
551551
/// This is useful for plain-text formats such as HTML and CSS.
552552
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
553553
fn guess_ext(path: &std::path::Path) -> Option<Mime> {
554-
let ext = path.extension().map(|p| p.to_str()).flatten();
554+
let ext = path.extension().and_then(|p| p.to_str());
555555
ext.and_then(Mime::from_extension)
556556
}
557557

@@ -565,7 +565,7 @@ mod test {
565565
async fn json_status() {
566566
#[derive(Debug, Deserialize)]
567567
struct Foo {
568-
inner: String,
568+
_inner: String,
569569
}
570570
let body = Body::empty();
571571
let res = body.into_json::<Foo>().await;
@@ -576,7 +576,7 @@ mod test {
576576
async fn form_status() {
577577
#[derive(Debug, Deserialize)]
578578
struct Foo {
579-
inner: String,
579+
_inner: String,
580580
}
581581
let body = Body::empty();
582582
let res = body.into_form::<Foo>().await;

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
@@ -96,8 +96,8 @@ impl ClearSiteData {
9696
let mut output = String::new();
9797
for (n, etag) in self.entries.iter().enumerate() {
9898
match n {
99-
0 => write!(output, "{}", etag.to_string()).unwrap(),
100-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
99+
0 => write!(output, "{}", etag).unwrap(),
100+
_ => write!(output, ", {}", etag).unwrap(),
101101
};
102102
}
103103

src/conditional/if_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ impl IfMatch {
8888
let mut output = String::new();
8989
for (n, etag) in self.entries.iter().enumerate() {
9090
match n {
91-
0 => write!(output, "{}", etag.to_string()).unwrap(),
92-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
91+
0 => write!(output, "{}", etag).unwrap(),
92+
_ => write!(output, ", {}", etag).unwrap(),
9393
};
9494
}
9595

src/conditional/if_none_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl IfNoneMatch {
9494
let mut output = String::new();
9595
for (n, etag) in self.entries.iter().enumerate() {
9696
match n {
97-
0 => write!(output, "{}", etag.to_string()).unwrap(),
98-
_ => write!(output, ", {}", etag.to_string()).unwrap(),
97+
0 => write!(output, "{}", etag).unwrap(),
98+
_ => write!(output, ", {}", etag).unwrap(),
9999
};
100100
}
101101

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/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl Serialize for Method {
391391
where
392392
S: Serializer,
393393
{
394-
serializer.serialize_str(&self.to_string())
394+
serializer.serialize_str(self.as_ref())
395395
}
396396
}
397397

src/mime/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ fn is_http_whitespace_char(c: char) -> bool {
153153

154154
/// [code point sequence collection](https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points)
155155
fn collect_code_point_sequence_char(input: &str, delimiter: char) -> (&str, &str) {
156-
input.split_at(input.find(delimiter).unwrap_or_else(|| input.len()))
156+
input.split_at(input.find(delimiter).unwrap_or(input.len()))
157157
}
158158

159159
/// [code point sequence collection](https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points)
160160
fn collect_code_point_sequence_slice<'a>(input: &'a str, delimiter: &[char]) -> (&'a str, &'a str) {
161-
input.split_at(input.find(delimiter).unwrap_or_else(|| input.len()))
161+
input.split_at(input.find(delimiter).unwrap_or(input.len()))
162162
}
163163

164164
/// [HTTP quoted string collection](https://fetch.spec.whatwg.org/#collect-an-http-quoted-string)

src/trace/server_timing/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn parse_entry(s: &str) -> crate::Result<Metric> {
6565
let millis: f64 = value.parse().map_err(|_| {
6666
format_err!("Server timing duration params must be a valid double-precision floating-point number.")
6767
})?;
68-
dur = Some(Duration::from_secs_f64(millis / 1000.0));
68+
dur = Some(Duration::from_secs_f64(millis) / 1000);
6969
}
7070
"desc" => {
7171
// Ensure quotes line up, and strip them from the resulting output

src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Serialize for Version {
2424
where
2525
S: Serializer,
2626
{
27-
serializer.serialize_str(&self.to_string())
27+
serializer.serialize_str(self.as_ref())
2828
}
2929
}
3030

0 commit comments

Comments
 (0)