From 4dc6ae61c66d2ecedb3dbd519dde89e8afc727a9 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sun, 30 Jun 2024 01:13:45 +0200 Subject: p2p: remove async-std from dev dependencies & clean up examples --- p2p/examples/shared/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'p2p/examples/shared') diff --git a/p2p/examples/shared/mod.rs b/p2p/examples/shared/mod.rs index 0e8079c..8c00446 100644 --- a/p2p/examples/shared/mod.rs +++ b/p2p/examples/shared/mod.rs @@ -1,8 +1,19 @@ -use std::{num::NonZeroUsize, sync::Arc, thread}; +use std::{io, num::NonZeroUsize, sync::Arc, thread}; +use blocking::unblock; use easy_parallel::Parallel; use smol::{channel, future, future::Future, Executor}; +#[allow(dead_code)] +pub async fn read_line_async() -> Result { + unblock(|| { + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + Ok(input) + }) + .await +} + /// Returns an estimate of the default amount of parallelism a program should use. /// see `std::thread::available_parallelism` pub fn available_parallelism() -> usize { -- cgit v1.2.3