1use std::future::Future;
2
3pub fn stdinix<F>(mut cl: F) -> eyre::Result<()>
4where
5 F: FnMut(&str) -> eyre::Result<()>,
6{
7 let mut buf = String::new();
8 while let Ok(true) = {
9 buf.clear();
10 std::io::stdin().read_line(&mut buf).map(|l| l > 0)
11 } {
12 cl(&buf)?;
13 }
14
15 Ok(())
16}
17
18pub async fn astdinix<F, Fut>(mut cl: F) -> eyre::Result<()>
19where
20 Fut: Future<Output = eyre::Result<()>>,
21 F: FnMut(String) -> Fut,
22{
23 let mut buf = String::new();
24 while let Ok(true) = {
25 buf.clear();
26 std::io::stdin().read_line(&mut buf).map(|l| l > 0)
27 } {
28 cl(buf.clone()).await?;
29 }
30
31 Ok(())
32}