lint: fix clippy warnings

This commit is contained in:
Jeremiah Senkpiel 2022-06-20 11:36:38 -07:00
parent 8101b90999
commit 1fe07df286
5 changed files with 8 additions and 8 deletions

View File

@ -283,7 +283,7 @@ impl Body {
pub async fn into_json<T: DeserializeOwned>(mut self) -> crate::Result<T> {
let mut buf = Vec::with_capacity(1024);
self.read_to_end(&mut buf).await?;
Ok(serde_json::from_slice(&buf).status(StatusCode::UnprocessableEntity)?)
serde_json::from_slice(&buf).status(StatusCode::UnprocessableEntity)
}
/// Creates a `Body` from a type, serializing it using form encoding.
@ -356,7 +356,7 @@ impl Body {
#[cfg(feature = "serde")]
pub async fn into_form<T: DeserializeOwned>(self) -> crate::Result<T> {
let s = self.into_string().await?;
Ok(serde_urlencoded::from_str(&s).status(StatusCode::UnprocessableEntity)?)
serde_urlencoded::from_str(&s).status(StatusCode::UnprocessableEntity)
}
/// Create a `Body` from a file named by a path.
@ -630,7 +630,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)
}

View File

@ -398,7 +398,7 @@ mod serde {
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
serializer.serialize_str(self.as_ref())
}
}
}

View File

@ -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)

View File

@ -116,7 +116,7 @@ impl StrictTransportSecurity {
} else if s == "preload" {
preload = true;
} else {
let (key, value) = match s.split_once("=") {
let (key, value) = match s.split_once('=') {
Some(kv) => kv,
None => continue, // We don't recognize the directive, continue.
};

View File

@ -31,7 +31,7 @@ mod serde {
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
serializer.serialize_str(self.as_ref())
}
}