From 317575131e22a10b74be6a7d16feba94cb24e9a4 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Thu, 20 Jun 2024 00:30:42 +0200 Subject: [PATCH] Simplify async channel example This removes a nested import (which I find hard to read) and removes an unnecessary type annotation. --- src/concurrency/async-control-flow/channels.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/concurrency/async-control-flow/channels.rs b/src/concurrency/async-control-flow/channels.rs index 3aefa055..19e49e6c 100644 --- a/src/concurrency/async-control-flow/channels.rs +++ b/src/concurrency/async-control-flow/channels.rs @@ -1,7 +1,7 @@ -use tokio::sync::mpsc::{self, Receiver}; +use tokio::sync::mpsc; -async fn ping_handler(mut input: Receiver<()>) { - let mut count: usize = 0; +async fn ping_handler(mut input: mpsc::Receiver<()>) { + let mut count = 0; while let Some(_) = input.recv().await { count += 1;