lock stdout
This commit is contained in:
parent
795a160e01
commit
bba405392c
@ -36,7 +36,7 @@ impl Interpolation {
|
|||||||
|
|
||||||
pub fn add_string(&mut self, s: String) {
|
pub fn add_string(&mut self, s: String) {
|
||||||
match self.contents.last_mut() {
|
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)),
|
_ => self.contents.push(InterpolationPart::String(s)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{stdin, stdout, BufWriter, Read, Write},
|
io::{stdin, stdout, Read, Write},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,16 +198,14 @@ fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
let (mut stdout_write, mut file_write);
|
let (mut stdout_write, mut file_write);
|
||||||
let buf_out: &mut dyn Write = if let Some(path) = matches.value_of("OUTPUT") {
|
let buf_out: &mut dyn Write = if let Some(path) = matches.value_of("OUTPUT") {
|
||||||
file_write = BufWriter::new(
|
file_write = OpenOptions::new()
|
||||||
OpenOptions::new()
|
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
.open(path)?,
|
.open(path)?;
|
||||||
);
|
|
||||||
&mut file_write
|
&mut file_write
|
||||||
} else {
|
} else {
|
||||||
stdout_write = BufWriter::new(stdout());
|
stdout_write = stdout().lock();
|
||||||
&mut stdout_write
|
&mut stdout_write
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user