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