Crates.io | stdinix |
lib.rs | stdinix |
version | 0.2.0 |
source | src |
created_at | 2020-02-09 21:40:07.14755 |
updated_at | 2022-09-13 23:02:56.382154 |
description | Utility function to reduce boilerplate for reading from stdin |
homepage | https://github.com/blakehawkins/stdinix |
repository | https://github.com/blakehawkins/stdinix |
max_upload_size | |
id | 206830 |
size | 2,931 |
Exposes a utility function to reduce boilerplate for reading from stdin.
use std::io::Result;
use stdinix::stdinix;
fn main() -> Result<()> {
stdinix(|buf| {
println!("{}", buf.rev().collect());
Ok(())
})
}
use std::io::Result;
fn main() -> Result<()> {
let mut buf = String::new();
while let Ok(true) = {
buf.clear();
std::io::stdin().read_line(&mut buf).map(|l| l > 0)
} {
println!("{}", buf.rev().collect());
}
Ok(())
}
use std::io::Result;
#[tokio::main]
async fn main() -> Result<()> {
let context = vec![0, 3];
astdinix(move |line| {
let context = context.clone();
async move {
println!("{} {}", line.bytes().nth(context[0]).unwrap(), line.bytes().nth(context[1]).unwrap());
Ok(())
}
})
.await
}