From 7d7134a68b486bad8ce7c134056a36da3e53526a Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Mon, 18 Sep 2023 19:14:29 +0800 Subject: [PATCH] fix(examples): clippy --- examples/graceful-shutdown/Cargo.toml | 2 +- examples/graceful-shutdown/src/main.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/graceful-shutdown/Cargo.toml b/examples/graceful-shutdown/Cargo.toml index 34d8f965..e76f6e0b 100644 --- a/examples/graceful-shutdown/Cargo.toml +++ b/examples/graceful-shutdown/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] viz.workspace = true -tokio = { workspace = true, features = [ "rt-multi-thread", "macros" ] } +tokio = { workspace = true, features = [ "rt-multi-thread", "macros", "time" ] } diff --git a/examples/graceful-shutdown/src/main.rs b/examples/graceful-shutdown/src/main.rs index 9a38ac71..6940c037 100644 --- a/examples/graceful-shutdown/src/main.rs +++ b/examples/graceful-shutdown/src/main.rs @@ -3,7 +3,7 @@ //! Graceful shutdown server. //! -//! See https://github.com/hyperium/hyper/blob/master/examples/graceful_shutdown.rs +//! See use std::{net::SocketAddr, sync::Arc, time::Duration}; use tokio::{net::TcpListener, pin}; @@ -44,7 +44,7 @@ async fn main() -> Result<()> { // result of polling the connection itself, // and also on tokio::time::sleep for the current timeout duration. for (iter, sleep_duration) in connection_timeouts_clone.iter().enumerate() { - println!("iter = {} sleep_duration = {:?}", iter, sleep_duration); + println!("iter = {iter} sleep_duration = {sleep_duration:?}"); tokio::select! { res = conn.as_mut() => { // Polling the connection returned a result. @@ -52,14 +52,14 @@ async fn main() -> Result<()> { // and break out of the loop. match res { Ok(()) => println!("after polling conn, no error"), - Err(e) => println!("error serving connection: {:?}", e), + Err(e) => println!("error serving connection: {e:?}"), }; break; } - _ = tokio::time::sleep(*sleep_duration) => { + () = tokio::time::sleep(*sleep_duration) => { // tokio::time::sleep returned a result. // Call graceful_shutdown on the connection and continue the loop. - println!("iter = {} got timeout_interval, calling conn.graceful_shutdown", iter); + println!("iter = {iter} got timeout_interval, calling conn.graceful_shutdown"); conn.as_mut().graceful_shutdown(); } }