Skip to content

Commit

Permalink
fix(examples): clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 18, 2023
1 parent b40b932 commit 7d7134a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/graceful-shutdown/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] }
10 changes: 5 additions & 5 deletions examples/graceful-shutdown/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! Graceful shutdown server.
//!
//! See https://github.com/hyperium/hyper/blob/master/examples/graceful_shutdown.rs
//! See <https://github.com/hyperium/hyper/blob/master/examples/graceful_shutdown.rs>
use std::{net::SocketAddr, sync::Arc, time::Duration};
use tokio::{net::TcpListener, pin};
Expand Down Expand Up @@ -44,22 +44,22 @@ 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.
// In this case print either the successful or error result for the connection
// 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();
}
}
Expand Down

0 comments on commit 7d7134a

Please sign in to comment.