From bba405392c88fb646b57cf23347a3babf290f74a Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 28 Dec 2022 12:08:44 -0500 Subject: [PATCH] lock stdout --- src/ast/interpolation.rs | 2 +- src/main.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ast/interpolation.rs b/src/ast/interpolation.rs index ca0ae00..0a284d2 100644 --- a/src/ast/interpolation.rs +++ b/src/ast/interpolation.rs @@ -36,7 +36,7 @@ impl Interpolation { pub fn add_string(&mut self, s: String) { match self.contents.last_mut() { - Some(InterpolationPart::String(existing)) => *existing += &s, + Some(InterpolationPart::String(existing)) => existing.push_str(&s), _ => self.contents.push(InterpolationPart::String(s)), } } diff --git a/src/main.rs b/src/main.rs index fcf8ebb..63636c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::{ fs::OpenOptions, - io::{stdin, stdout, BufWriter, Read, Write}, + io::{stdin, stdout, Read, Write}, path::Path, }; @@ -198,16 +198,14 @@ fn main() -> std::io::Result<()> { let (mut stdout_write, mut file_write); let buf_out: &mut dyn Write = if let Some(path) = matches.value_of("OUTPUT") { - file_write = BufWriter::new( - OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(path)?, - ); + file_write = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(path)?; &mut file_write } else { - stdout_write = BufWriter::new(stdout()); + stdout_write = stdout().lock(); &mut stdout_write };