lock stdout

This commit is contained in:
Connor Skees 2022-12-28 12:08:44 -05:00
parent 795a160e01
commit bba405392c
2 changed files with 8 additions and 10 deletions

View File

@ -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)),
}
}

View File

@ -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
};