Skip to content

Commit c825f07

Browse files
committed
refactor(tee): implement Copy for OutputErrorMode
1 parent 9efa5a3 commit c825f07

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/uu/tee/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub mod options {
1818
pub const OUTPUT_ERROR: &str = "output-error";
1919
}
2020

21-
#[derive(Clone, Debug)]
21+
#[derive(Clone, Copy, Debug)]
2222
pub enum OutputErrorMode {
2323
/// Diagnose write error on any output
2424
Warn,

src/uu/tee/src/tee.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn tee(options: &Options) -> Result<()> {
8484
},
8585
);
8686

87-
let mut output = MultiWriter::new(writers, options.output_error.clone());
87+
let mut output = MultiWriter::new(writers, options.output_error);
8888
let input = NamedReader { inner: stdin() };
8989

9090
#[cfg(target_os = "linux")]
@@ -197,7 +197,7 @@ impl MultiWriter {
197197
}
198198

199199
fn process_error(
200-
mode: Option<&OutputErrorMode>,
200+
mode: Option<OutputErrorMode>,
201201
e: Error,
202202
writer: &NamedWriter,
203203
ignored_errors: &mut usize,
@@ -222,8 +222,8 @@ fn process_error(
222222
impl Write for MultiWriter {
223223
fn write(&mut self, buf: &[u8]) -> Result<usize> {
224224
let mut aborted = None;
225-
let mode = self.output_error_mode.clone();
226225
let mut errors = 0;
226+
let mode = self.output_error_mode;
227227
self.writers.retain_mut(|writer| {
228228
let res = (|| {
229229
writer.write_all(buf)?;
@@ -232,7 +232,7 @@ impl Write for MultiWriter {
232232
match res {
233233
Ok(()) => true,
234234
Err(e) => {
235-
if let Err(e) = process_error(mode.as_ref(), e, writer, &mut errors) {
235+
if let Err(e) = process_error(mode, e, writer, &mut errors) {
236236
aborted.get_or_insert(e);
237237
}
238238
false

0 commit comments

Comments
 (0)