let topo = &graph.crates_in_topological_order();
cb(PrimeCachesProgress::Started);
+ let _d = stdx::defer(|| cb(PrimeCachesProgress::Finished));
// FIXME: This would be easy to parallelize, since it's in the ideal ordering for that.
// Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks
});
db.crate_def_map(*krate);
}
-
- cb(PrimeCachesProgress::Finished);
}
start..start + len
}
+pub fn defer<F: FnOnce()>(f: F) -> impl Drop {
+ struct D<F: FnOnce()>(Option<F>);
+ impl<F: FnOnce()> Drop for D<F> {
+ fn drop(&mut self) {
+ if let Some(f) = self.0.take() {
+ f()
+ }
+ }
+ }
+ D(Some(f))
+}
+
#[repr(transparent)]
pub struct JodChild(pub std::process::Child);