Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all failing clippy lints for backports branch #399

Merged
merged 4 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl AsyncRead for Body {
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
let mut buf = match self.length {
let buf = match self.length {
None => buf,
Some(length) if length == self.bytes_read => return Poll::Ready(Ok(0)),
Some(length) => {
Expand All @@ -516,7 +516,7 @@ impl AsyncRead for Body {
}
};

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

Expand All @@ -565,7 +565,7 @@ mod test {
async fn json_status() {
#[derive(Debug, Deserialize)]
struct Foo {
inner: String,
_inner: String,
}
let body = Body::empty();
let res = body.into_json::<Foo>().await;
Expand All @@ -576,7 +576,7 @@ mod test {
async fn form_status() {
#[derive(Debug, Deserialize)]
struct Foo {
inner: String,
_inner: String,
}
let body = Body::empty();
let res = body.into_form::<Foo>().await;
Expand Down
2 changes: 1 addition & 1 deletion src/cache/cache_control/cache_directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl CacheDirective {
return Ok(None);
}

s.to_lowercase();
let s = s.to_lowercase();
let mut parts = s.split('=');
let next = parts.next().unwrap();

Expand Down
4 changes: 2 additions & 2 deletions src/cache/clear_site_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ impl ClearSiteData {
let mut output = String::new();
for (n, etag) in self.entries.iter().enumerate() {
match n {
0 => write!(output, "{}", etag.to_string()).unwrap(),
_ => write!(output, ", {}", etag.to_string()).unwrap(),
0 => write!(output, "{}", etag).unwrap(),
_ => write!(output, ", {}", etag).unwrap(),
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/conditional/if_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ impl IfMatch {
let mut output = String::new();
for (n, etag) in self.entries.iter().enumerate() {
match n {
0 => write!(output, "{}", etag.to_string()).unwrap(),
_ => write!(output, ", {}", etag.to_string()).unwrap(),
0 => write!(output, "{}", etag).unwrap(),
_ => write!(output, ", {}", etag).unwrap(),
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/conditional/if_none_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl IfNoneMatch {
let mut output = String::new();
for (n, etag) in self.entries.iter().enumerate() {
match n {
0 => write!(output, "{}", etag.to_string()).unwrap(),
_ => write!(output, ", {}", etag.to_string()).unwrap(),
0 => write!(output, "{}", etag).unwrap(),
_ => write!(output, ", {}", etag).unwrap(),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Error {

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

/// Converts anything which implements `Display` into an `http_types::Error`.
Expand Down
2 changes: 1 addition & 1 deletion src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl Serialize for Method {
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
serializer.serialize_str(self.as_ref())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/mime/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ fn is_http_whitespace_char(c: char) -> bool {

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

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

/// [HTTP quoted string collection](https://fetch.spec.whatwg.org/#collect-an-http-quoted-string)
Expand Down
2 changes: 1 addition & 1 deletion src/trace/server_timing/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn parse_entry(s: &str) -> crate::Result<Metric> {
let millis: f64 = value.parse().map_err(|_| {
format_err!("Server timing duration params must be a valid double-precision floating-point number.")
})?;
dur = Some(Duration::from_secs_f64(millis / 1000.0));
dur = Some(Duration::from_secs_f64(millis) / 1000);
}
"desc" => {
// Ensure quotes line up, and strip them from the resulting output
Expand Down
2 changes: 1 addition & 1 deletion src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Serialize for Version {
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
serializer.serialize_str(self.as_ref())
}
}

Expand Down