Collect result in format CLI (#6924)

This commit is contained in:
Charlie Marsh 2023-08-27 16:02:18 -04:00 committed by GitHub
parent 292fdd978e
commit a871714705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,7 +32,7 @@ pub(crate) fn format(cli: &Arguments, overrides: &Overrides) -> Result<ExitStatu
return Ok(ExitStatus::Success);
}
let all_success = paths
let result = paths
.into_par_iter()
.map(|dir_entry| {
let dir_entry = dir_entry?;
@ -57,21 +57,18 @@ pub(crate) fn format(cli: &Arguments, overrides: &Overrides) -> Result<ExitStatu
format_path(path, options)
})
.map(|result| {
match result {
Ok(()) => true,
Err(err) => {
// The inner errors are all flat, i.e., none of them has a source.
#[allow(clippy::print_stderr)]
{
eprintln!("{}", err.to_string().red().bold());
}
false
if let Err(err) = result.as_ref() {
// The inner errors are all flat, i.e., none of them has a source.
#[allow(clippy::print_stderr)]
{
eprintln!("{}", err.to_string().red().bold());
}
}
result
})
.all(|success| success);
.collect::<Result<Vec<_>, _>>();
if all_success {
if result.is_ok() {
Ok(ExitStatus::Success)
} else {
Ok(ExitStatus::Error)