Rust input/output
From wikinotes
Documentation
std::fs
https://doc.rust-lang.org/std/fs/index.html
Stdin, Stdout, Stderr
println!("out"); // write to stdout eprintln!("err"); // write to stderrread from stdin (wait indefinitely if nothing is written)
use std::io; use std::io::BufRead; let stdin = io::stdin(); let handle = stdin.lock(); let lines: Vec<String> = handle .lines() .map(|res| res.unwrap_or_default()) .collect(); print!("START\n{}\nFINISH\n", lines.join("\n"));TODO:
read from stdin, checking if it's a tty or a pipe
User Input
let name = String::new(); io::stdin().read_line(&mut name);