4 ms·
Did you mean something like this? use std::io::{self, Read}; fn main() { let stdin = io::stdin(); let mut data = vec![]; stdin.
by rnestler 10y ago
Did you mean something like this?
use std::io::{self, Read};
fn main() {
let stdin = io::stdin();
let mut data = vec![];
stdin.lock().read_to_end(&mut data)
.expect("Reading stdin failed");
}
- dbaupp 10y ago(FWIW, You could golf that to io::stdin().read_to_end(...), because the Read implementation for Stdin does the same locking internally: https://github.com/rust-lang/rust/blob/8f62c2920077eb5cb81323142fc5dbe6ae8813c0/src/libstd/io/stdio.rs#L298 https://github.com/rust-lang/rust/blob/8f62c2920077eb5cb8132... .)