qubit_function/functions/bi_mutating_function/box_conditional_bi_mutating_function.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9//! Defines the `BoxConditionalBiMutatingFunction` public type.
10
11#![allow(unused_imports)]
12
13use super::*;
14
15// ============================================================================
16// BoxConditionalBiMutatingFunction - Box-based Conditional BiMutatingFunction
17// ============================================================================
18
19/// BoxConditionalBiMutatingFunction struct
20///
21/// A conditional bi-mutating-function that only executes when a bi-predicate is
22/// satisfied. Uses `BoxBiMutatingFunction` and `BoxBiPredicate` for single
23/// ownership semantics.
24///
25/// This type is typically created by calling `BoxBiMutatingFunction::when()` and is
26/// designed to work with the `or_else()` method to create if-then-else logic.
27///
28/// # Features
29///
30/// - **Single Ownership**: Not cloneable, ownership moves on use
31/// - **Conditional Execution**: Only computes when bi-predicate returns `true`
32/// - **Chainable**: Can add `or_else` branch to create if-then-else logic
33/// - **Implements BiMutatingFunction**: Can be used anywhere a `BiMutatingFunction` is expected
34///
35/// # Author
36///
37/// Haixing Hu
38pub struct BoxConditionalBiMutatingFunction<T, U, R> {
39 pub(super) function: BoxBiMutatingFunction<T, U, R>,
40 pub(super) predicate: BoxBiPredicate<T, U>,
41}
42
43// Implement BoxConditionalBiMutatingFunction
44impl_box_conditional_function!(
45 BoxConditionalBiMutatingFunction<T, U, R>,
46 BoxBiMutatingFunction,
47 BiMutatingFunction
48);
49
50// Use macro to generate Debug and Display implementations
51impl_conditional_function_debug_display!(BoxConditionalBiMutatingFunction<T, U, R>);