Skip to content

Commit 1fe07df

Browse files
committed
lint: fix clippy warnings
1 parent 8101b90 commit 1fe07df

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/body.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl Body {
283283
pub async fn into_json<T: DeserializeOwned>(mut self) -> crate::Result<T> {
284284
let mut buf = Vec::with_capacity(1024);
285285
self.read_to_end(&mut buf).await?;
286-
Ok(serde_json::from_slice(&buf).status(StatusCode::UnprocessableEntity)?)
286+
serde_json::from_slice(&buf).status(StatusCode::UnprocessableEntity)
287287
}
288288

289289
/// Creates a `Body` from a type, serializing it using form encoding.
@@ -356,7 +356,7 @@ impl Body {
356356
#[cfg(feature = "serde")]
357357
pub async fn into_form<T: DeserializeOwned>(self) -> crate::Result<T> {
358358
let s = self.into_string().await?;
359-
Ok(serde_urlencoded::from_str(&s).status(StatusCode::UnprocessableEntity)?)
359+
serde_urlencoded::from_str(&s).status(StatusCode::UnprocessableEntity)
360360
}
361361

362362
/// 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>> {
630630
/// This is useful for plain-text formats such as HTML and CSS.
631631
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
632632
fn guess_ext(path: &std::path::Path) -> Option<Mime> {
633-
let ext = path.extension().map(|p| p.to_str()).flatten();
633+
let ext = path.extension().and_then(|p| p.to_str());
634634
ext.and_then(Mime::from_extension)
635635
}
636636

src/method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ mod serde {
398398
where
399399
S: Serializer,
400400
{
401-
serializer.serialize_str(&self.to_string())
401+
serializer.serialize_str(self.as_ref())
402402
}
403403
}
404404
}

src/mime/parse.rs

+2-2
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/security/strict_transport_security.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl StrictTransportSecurity {
116116
} else if s == "preload" {
117117
preload = true;
118118
} else {
119-
let (key, value) = match s.split_once("=") {
119+
let (key, value) = match s.split_once('=') {
120120
Some(kv) => kv,
121121
None => continue, // We don't recognize the directive, continue.
122122
};

src/version.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod serde {
3131
where
3232
S: Serializer,
3333
{
34-
serializer.serialize_str(&self.to_string())
34+
serializer.serialize_str(self.as_ref())
3535
}
3636
}
3737

0 commit comments

Comments
 (0)