Skip to content

Instantly share code, notes, and snippets.

@mre
Last active October 9, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mre/d1f7153ad37757c179d6e2f96cdea201 to your computer and use it in GitHub Desktop.
Save mre/d1f7153ad37757c179d6e2f96cdea201 to your computer and use it in GitHub Desktop.
The yes unix command written in Rust
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