mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-19 04:21:06 +00:00
inline a closure which is called only once
This commit is contained in:
parent
92ba42a602
commit
dc0acbbb90
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user