feat(op): allow import without state (#7661)

This commit is contained in:
Emilia Hane
2024-04-19 14:17:31 +02:00
committed by GitHub
parent cf163ba9d8
commit f4dda95cbd
3 changed files with 127 additions and 92 deletions

View File

@@ -187,6 +187,18 @@ where
self
}
/// Disables all given stages. See [`disable`](Self::disable).
pub fn disable_all(mut self, stages: &[StageId]) -> Self {
for stage_id in stages {
let entry = self
.stages
.get_mut(stage_id)
.expect("Cannot disable a stage that is not in the set.");
entry.enabled = false;
}
self
}
/// Disables the given stage if the given closure returns true.
///
/// See [Self::disable]
@@ -200,6 +212,19 @@ where
self
}
/// Disables all given stages if the given closure returns true.
///
/// See [Self::disable]
pub fn disable_all_if<F>(self, stages: &[StageId], f: F) -> Self
where
F: FnOnce() -> bool,
{
if f() {
return self.disable_all(stages)
}
self
}
/// Consumes the builder and returns the contained [`Stage`]s in the order specified.
pub fn build(mut self) -> Vec<Box<dyn Stage<DB>>> {
let mut stages = Vec::new();