pub struct Choice { /* private fields */ }Expand description
Choice composition - conditional execution
Executes one of two branches based on a predicate function.
If the predicate returns true, the if_true branch executes;
otherwise, the if_false branch executes (if provided).
§Example
ⓘ
let choice = Choice::new(
|ctx| ctx.get_variable("dry_run").is_some(),
dry_run_composition,
).with_else(real_execution_composition);Implementations§
Source§impl Choice
impl Choice
Sourcepub fn new(
predicate: impl Fn(&ExecutionContext) -> bool + Send + Sync + 'static,
if_true: impl Composition + 'static,
) -> Self
pub fn new( predicate: impl Fn(&ExecutionContext) -> bool + Send + Sync + 'static, if_true: impl Composition + 'static, ) -> Self
Creates a new choice composition
§Arguments
predicate- Function that evaluates the context to choose a branchif_true- Composition to execute if predicate returns true
Sourcepub fn with_else(self, if_false: impl Composition + 'static) -> Self
pub fn with_else(self, if_false: impl Composition + 'static) -> Self
Adds an else branch to execute if the predicate returns false
Trait Implementations§
Source§impl Composition for Choice
impl Composition for Choice
Auto Trait Implementations§
impl Freeze for Choice
impl !RefUnwindSafe for Choice
impl Send for Choice
impl Sync for Choice
impl Unpin for Choice
impl UnsafeUnpin for Choice
impl !UnwindSafe for Choice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more