inline a closure which is called only once

This commit is contained in:
rhysd authored and David Peter committed 2021-10-23 13:04:24 +02:00
1 parent 92ba42a602
commit dc0acbbb90
1 file changed
+5 -9
+5 -9
View File
@@ -89,15 +89,7 @@ impl<'b> Controller<'b> {
let writer = output_type.handle()?;
let mut no_errors: bool = true;
let stderr = io::stderr();
let print_error = |error: &Error, write: &mut dyn Write| {
if attached_to_pager {
handle_error(error, write);
} else {
handle_error(error, &mut stderr.lock());
}
};
for (index, input) in inputs.into_iter().enumerate() {
let identifier = stdout_identifier.as_ref();
@@ -109,7 +101,11 @@ impl<'b> Controller<'b> {
self.print_input(input, writer, DummyStdin, identifier, is_first)
};
if let Err(error) = result {
print_error(&error, writer);
if attached_to_pager {
handle_error(&error, writer);
} else {
handle_error(&error, &mut stderr.lock());
}
no_errors = false;
}
}