Skip to content

Commit

Permalink
buffer writes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Aug 24, 2021
1 parent 96306f8 commit 32d71b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
@@ -1,7 +1,7 @@
use clap::{crate_authors, crate_version, App, Arg};
use color_eyre::eyre::{ContextCompat, Result, WrapErr};
use rayon::prelude::*;
use std::io::{self, stdin, BufRead};
use std::io::{self, stdin, stdout, BufRead, BufWriter, Write};
use strsim::levenshtein;

fn main() {
Expand Down Expand Up @@ -37,8 +37,9 @@ fn try_main() -> Result<()> {

lines.par_sort_by_key(|candidate| levenshtein(target, candidate));

let mut out = BufWriter::new(stdout());
for candidate in lines {
println!("{}", candidate);
writeln!(out, "{}", candidate).context("could not write to stdout")?;
}

Ok(())
Expand Down

0 comments on commit 32d71b4

Please sign in to comment.