Replace fold/reduce over Result::and with collect
Not only is this tidier, but it avoids making these iterators Rayon-specific.
This commit is contained in:
parent
d11f4aa56a
commit
088b3df79a
|
@ -363,9 +363,7 @@ impl Processor {
|
||||||
let target = self.resized_path.join(Self::op_filename(*hash, op.collision_id));
|
let target = self.resized_path.join(Self::op_filename(*hash, op.collision_id));
|
||||||
op.perform(&self.content_path, &target)
|
op.perform(&self.content_path, &target)
|
||||||
.chain_err(|| format!("Failed to process image: {}", op.source))
|
.chain_err(|| format!("Failed to process image: {}", op.source))
|
||||||
})
|
}).collect::<Result<()>>()
|
||||||
.fold(|| Ok(()), Result::and)
|
|
||||||
.reduce(|| Ok(()), Result::and)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,13 +272,11 @@ impl Site {
|
||||||
let insert_anchor = pages_insert_anchors[&page.file.path];
|
let insert_anchor = pages_insert_anchors[&page.file.path];
|
||||||
page.render_markdown(permalinks, tera, config, base_path, insert_anchor)
|
page.render_markdown(permalinks, tera, config, base_path, insert_anchor)
|
||||||
})
|
})
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()?;
|
||||||
.reduce(|| Ok(()), Result::and)?;
|
|
||||||
|
|
||||||
self.sections.par_iter_mut()
|
self.sections.par_iter_mut()
|
||||||
.map(|(_, section)| section.render_markdown(permalinks, tera, config, base_path))
|
.map(|(_, section)| section.render_markdown(permalinks, tera, config, base_path))
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()?;
|
||||||
.reduce(|| Ok(()), Result::and)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -717,8 +715,7 @@ impl Site {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()
|
||||||
.reduce(|| Ok(()), Result::and)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What it says on the tin
|
/// What it says on the tin
|
||||||
|
@ -847,8 +844,7 @@ impl Site {
|
||||||
.pages
|
.pages
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|p| self.render_page(p))
|
.map(|p| self.render_page(p))
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()?;
|
||||||
.reduce(|| Ok(()), Result::and)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !section.meta.render {
|
if !section.meta.render {
|
||||||
|
@ -886,8 +882,7 @@ impl Site {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|s| self.render_section(s, true))
|
.map(|s| self.render_section(s, true))
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()
|
||||||
.reduce(|| Ok(()), Result::and)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renders all pages that do not belong to any sections
|
/// Renders all pages that do not belong to any sections
|
||||||
|
@ -924,7 +919,6 @@ impl Site {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.fold(|| Ok(()), Result::and)
|
.collect::<Result<()>>()
|
||||||
.reduce(|| Ok(()), Result::and)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue