Last active
October 9, 2017 21:40
-
-
Save mre/d1f7153ad37757c179d6e2f96cdea201 to your computer and use it in GitHub Desktop.
The yes unix command written in Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::io::BufWriter; | |
use std::io::{self, Write}; | |
const BUFSIZE: usize = 8192; | |
fn main() { | |
let expletive = env::args().nth(1).unwrap_or("y".into()); | |
let mut writer = BufWriter::with_capacity(BUFSIZE, io::stdout()); | |
loop { | |
writeln!(writer, "{}", expletive).expect("Can't write to BufWriter"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment