diff --git a/crates/core/src/catcher.rs b/crates/core/src/catcher.rs index 6ad79a074..4f2328b0a 100644 --- a/crates/core/src/catcher.rs +++ b/crates/core/src/catcher.rs @@ -310,7 +310,7 @@ pub fn write_error_default(req: &Request, res: &mut Response, footer: Option<&st header::CONTENT_TYPE, format.to_string().parse().expect("invalid `Content-Type`"), ); - res.write_body(data).ok(); + let _ = res.write_body(data); } #[cfg(test)] diff --git a/crates/core/src/conn/proto.rs b/crates/core/src/conn/proto.rs index 3a62cd663..0b846b592 100644 --- a/crates/core/src/conn/proto.rs +++ b/crates/core/src/conn/proto.rs @@ -129,7 +129,7 @@ impl HttpBuilder { // Init graceful shutdown for connection (`GOAWAY` for `HTTP/2` or disabling `keep-alive` for `HTTP/1`) Pin::new(&mut conn).graceful_shutdown(); - conn.await.ok(); + let _ = conn.await; } } } @@ -144,7 +144,7 @@ impl HttpBuilder { // Init graceful shutdown for connection (`GOAWAY` for `HTTP/2` or disabling `keep-alive` for `HTTP/1`) Pin::new(&mut conn).graceful_shutdown(); - conn.await.ok(); + let _ = conn.await; } } } @@ -160,7 +160,7 @@ impl HttpBuilder { } } (None, None) => { - conn.await.ok(); + let _ = conn.await; } } } @@ -191,7 +191,7 @@ impl HttpBuilder { // Init graceful shutdown for connection (`GOAWAY` for `HTTP/2` or disabling `keep-alive` for `HTTP/1`) Pin::new(&mut conn).graceful_shutdown(); - conn.await.ok(); + let _ = conn.await; } } } @@ -206,7 +206,7 @@ impl HttpBuilder { // Init graceful shutdown for connection (`GOAWAY` for `HTTP/2` or disabling `keep-alive` for `HTTP/1`) Pin::new(&mut conn).graceful_shutdown(); - conn.await.ok(); + let _ = conn.await; } } } @@ -222,7 +222,7 @@ impl HttpBuilder { } } (None, None) => { - conn.await.ok(); + let _ = conn.await; } } } diff --git a/crates/core/src/http/form.rs b/crates/core/src/http/form.rs index 7921d9f97..64733e5da 100644 --- a/crates/core/src/http/form.rs +++ b/crates/core/src/http/form.rs @@ -191,8 +191,8 @@ impl Drop for FilePart { let path = self.path.clone(); let temp_dir = temp_dir.to_owned(); tokio::task::spawn_blocking(move || { - std::fs::remove_file(&path).ok(); - std::fs::remove_dir(temp_dir).ok(); + let _ = std::fs::remove_file(&path); + let _ = std::fs::remove_dir(temp_dir); }); } } diff --git a/crates/core/src/serde/flat_value.rs b/crates/core/src/serde/flat_value.rs index 489c19340..032587d1b 100644 --- a/crates/core/src/serde/flat_value.rs +++ b/crates/core/src/serde/flat_value.rs @@ -113,7 +113,7 @@ impl<'de> Deserializer<'de> for FlatValue<'de> { { let mut items = std::mem::take(&mut self.0); let single_mode = if items.len() == 1 { - if let Some(item) = items.get(0) { + if let Some(item) = items.first() { item.0.starts_with('[') && item.0.ends_with(']') } else { false diff --git a/crates/core/src/serde/request.rs b/crates/core/src/serde/request.rs index c350a0d62..9f1dc646c 100644 --- a/crates/core/src/serde/request.rs +++ b/crates/core/src/serde/request.rs @@ -29,12 +29,12 @@ where match ctype.subtype() { mime::WWW_FORM_URLENCODED | mime::FORM_DATA => { if metadata.has_body_required() { - req.form_data().await.ok(); + let _ = req.form_data().await; } } mime::JSON => { if metadata.has_body_required() { - req.payload().await.ok(); + let _ = req.payload().await; } } _ => {} diff --git a/crates/core/src/server.rs b/crates/core/src/server.rs index cb8f715a3..b208072e8 100644 --- a/crates/core/src/server.rs +++ b/crates/core/src/server.rs @@ -45,7 +45,7 @@ impl ServerHandle { /// /// Call this function will stop server immediately. pub fn stop_forcible(&self) { - self.tx_cmd.send(ServerCommand::StopForcible).ok(); + let _ = self.tx_cmd.send(ServerCommand::StopForcible); } /// Graceful stop server. @@ -81,7 +81,7 @@ impl ServerHandle { /// } /// ``` pub fn stop_graceful(&self, timeout: impl Into>) { - self.tx_cmd.send(ServerCommand::StopGraceful(timeout.into())).ok(); + let _ = self.tx_cmd.send(ServerCommand::StopGraceful(timeout.into())); } } @@ -159,7 +159,7 @@ impl Server { /// /// Call this function will stop server immediately. pub fn stop_forcible(&self) { - self.tx_cmd.send(ServerCommand::StopForcible).ok(); + let _ = self.tx_cmd.send(ServerCommand::StopForcible); } /// Graceful stop server. @@ -168,7 +168,7 @@ impl Server { /// You can specify a timeout to force stop server. /// If `timeout` is `None`, it will wait util all connections are closed. pub fn stop_graceful(&self, timeout: impl Into>) { - self.tx_cmd.send(ServerCommand::StopGraceful(timeout.into())).ok(); + let _ = self.tx_cmd.send(ServerCommand::StopGraceful(timeout.into())); } } @@ -382,7 +382,7 @@ impl Server { let builder = builder.clone(); tokio::spawn(async move { - conn.serve(handler, builder, None).await.ok(); + let _ = conn.serve(handler, builder, None).await; }); }, Err(e) => { diff --git a/crates/extra/src/request_id.rs b/crates/extra/src/request_id.rs index 9d7c0eb6d..df25f3a65 100644 --- a/crates/extra/src/request_id.rs +++ b/crates/extra/src/request_id.rs @@ -122,7 +122,7 @@ impl Handler for RequestId { return; } let id = self.generator.generate(req, depot); - req.add_header(self.header_name.clone(), &id, true).ok(); + let _ = req.add_header(self.header_name.clone(), &id, true); depot.insert(REQUST_ID_KEY, id); } } diff --git a/crates/jwt-auth/src/oidc/mod.rs b/crates/jwt-auth/src/oidc/mod.rs index b2412858a..5430b5525 100644 --- a/crates/jwt-auth/src/oidc/mod.rs +++ b/crates/jwt-auth/src/oidc/mod.rs @@ -213,7 +213,7 @@ impl OidcDecoder { tracing::info!("Spawning Task to re-validate JWKS"); let a = self.clone(); tokio::task::spawn(async move { - a.update_cache().await.ok(); + let _ = a.update_cache().await; a.cache_state.set_is_revalidating(false); a.notifier.notify_waiters(); }); diff --git a/crates/macros/src/extract.rs b/crates/macros/src/extract.rs index 4e11b53b4..112c027fe 100644 --- a/crates/macros/src/extract.rs +++ b/crates/macros/src/extract.rs @@ -123,7 +123,7 @@ impl Parse for ExtractFieldInfo { return Err(input.error("unexpected attribute")); } } - input.parse::().ok(); + let _ = input.parse::(); } Ok(extract) } diff --git a/crates/oapi-macros/src/parameter/mod.rs b/crates/oapi-macros/src/parameter/mod.rs index 15e14fa9a..2b1437ff0 100644 --- a/crates/oapi-macros/src/parameter/mod.rs +++ b/crates/oapi-macros/src/parameter/mod.rs @@ -184,7 +184,7 @@ impl Parse for ValueParameter<'_> { if input.fork().parse::().is_ok() { parameter.parameter_in = Some(input.parse()?); - input.parse::().ok(); + let _ = input.parse::(); } let (schema_features, parameter_features) = input diff --git a/crates/oapi/docs/derive_to_response.md b/crates/oapi/docs/derive_to_response.md index 4c499dc44..e4a2c82da 100644 --- a/crates/oapi/docs/derive_to_response.md +++ b/crates/oapi/docs/derive_to_response.md @@ -140,7 +140,7 @@ impl Scribe for PersonResponse { fn render(self, res: &mut Response) { res.headers_mut() .insert(CONTENT_TYPE, HeaderValue::from_static("text/plain; charset=utf-8")); - res.write_body(self.value).ok(); + let _ = res.write_body(self.value); } } diff --git a/crates/oapi/docs/derive_to_responses.md b/crates/oapi/docs/derive_to_responses.md index 8ce026c58..71da187a9 100644 --- a/crates/oapi/docs/derive_to_responses.md +++ b/crates/oapi/docs/derive_to_responses.md @@ -102,7 +102,7 @@ impl Scribe for UserResponses { fn render(self, res: &mut Response) { res.headers_mut() .insert(CONTENT_TYPE, HeaderValue::from_static("text/plain; charset=utf-8")); - res.write_body(format!("{self:#?}")).ok(); + let _ = res.write_body(format!("{self:#?}")); } } diff --git a/crates/serve-static/src/dir.rs b/crates/serve-static/src/dir.rs index d86e85ab7..bed2ab2d1 100644 --- a/crates/serve-static/src/dir.rs +++ b/crates/serve-static/src/dir.rs @@ -507,25 +507,23 @@ fn list_xml(current: &CurrentInfo) -> String { } else { let format = format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); for dir in ¤t.dirs { - write!( + let _ = write!( ftxt, "{}{}{}", dir.name, dir.modified.format(&format).expect("format time failed"), encode_url_path(&dir.name), - ) - .ok(); + ); } for file in ¤t.files { - write!( + let _ = write!( ftxt, "{}{}{}{}", file.name, file.modified.format(&format).expect("format time failed"), file.size, encode_url_path(&file.name), - ) - .ok(); + ); } } ftxt.push_str(""); @@ -578,31 +576,29 @@ fn list_html(current: &CurrentInfo) -> String { header_links(¤t.path) ); if current.dirs.is_empty() && current.files.is_empty() { - write!(ftxt, "

No files

").ok(); + let _ = write!(ftxt, "

No files

"); } else { - write!(ftxt, "
").ok(); + let _ = write!(ftxt, "" - ) - .ok(); + ); let format = format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); for dir in ¤t.dirs { - write!( + let _ = write!( ftxt, r#""#, DIR_ICON, encode_url_path(&dir.name), dir.name, dir.modified.format(&format).expect("format time failed"), - ) - .ok(); + ); } for file in ¤t.files { - write!( + let _ = write!( ftxt, r#""#, FILE_ICON, @@ -610,16 +606,14 @@ fn list_html(current: &CurrentInfo) -> String { file.name, file.modified.format(&format).expect("format time failed"), human_size(file.size) - ) - .ok(); + ); } - write!(ftxt, "
"); if !(current.path.is_empty() || current.path == "/") { - write!(ftxt, "[..]").ok(); + let _ = write!(ftxt, "[..]"); } - write!( + let _ = write!( ftxt, "NameLast modifiedSize
{}{}{}
{}{}{}{}
").ok(); + let _ = write!(ftxt, "
"); } - write!( + let _ = write!( ftxt, r#"
"# - ) - .ok(); + ); ftxt } #[inline] diff --git a/crates/serve-static/src/embed.rs b/crates/serve-static/src/embed.rs index 228d865ec..daffecc4f 100644 --- a/crates/serve-static/src/embed.rs +++ b/crates/serve-static/src/embed.rs @@ -73,10 +73,10 @@ fn render_embedded_data( match data { Cow::Borrowed(data) => { - res.write_body(data).ok(); + let _ = res.write_body(data); } Cow::Owned(data) => { - res.write_body(data).ok(); + let _ = res.write_body(data); } } } diff --git a/examples/otel-jaeger/src/exporter.rs b/examples/otel-jaeger/src/exporter.rs index 353b3bb4f..7437c757f 100644 --- a/examples/otel-jaeger/src/exporter.rs +++ b/examples/otel-jaeger/src/exporter.rs @@ -23,8 +23,7 @@ impl Exporter { let mut body = Vec::new(); match encoder.encode(&metric_families, &mut body) { Ok(()) => { - res.add_header(header::CONTENT_TYPE, "text/javascript; charset=utf-8", true) - .ok(); + let _ = res.add_header(header::CONTENT_TYPE, "text/javascript; charset=utf-8", true); res.body(body); } Err(_) => {