Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Input-loop/Rust/input-loop.rust
Normal file
19
Task/Input-loop/Rust/input-loop.rust
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use std::io::{self, BufReader, Read, BufRead};
|
||||
use std::fs::File;
|
||||
|
||||
fn main() {
|
||||
print_by_line(io::stdin())
|
||||
.expect("Could not read from stdin");
|
||||
|
||||
File::open("/etc/fstab")
|
||||
.and_then(print_by_line)
|
||||
.expect("Could not read from file");
|
||||
}
|
||||
|
||||
fn print_by_line<T: Read>(reader: T) -> io::Result<()> {
|
||||
let buffer = BufReader::new(reader);
|
||||
for line in buffer.lines() {
|
||||
println!("{}", line?)
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue