qubit_function/functions/bi_mutating_function/arc_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 `ArcConditionalBiMutatingFunction` public type.
10
11#![allow(unused_imports)]
12
13use super::*;
14
15// ============================================================================
16// ArcConditionalBiMutatingFunction - Arc-based Conditional BiMutatingFunction
17// ============================================================================
18
19/// ArcConditionalBiMutatingFunction struct
20///
21/// A thread-safe conditional bi-mutating-function that only executes when a
22/// bi-predicate is satisfied. Uses `ArcBiMutatingFunction` and `ArcBiPredicate` for
23/// shared ownership across threads.
24///
25/// This type is typically created by calling `ArcBiMutatingFunction::when()` and is
26/// designed to work with the `or_else()` method to create if-then-else logic.
27///
28/// # Features
29///
30/// - **Shared Ownership**: Cloneable via `Arc`, multiple owners allowed
31/// - **Thread-Safe**: Implements `Send + Sync`, safe for concurrent use
32/// - **Conditional Execution**: Only computes when bi-predicate returns `true`
33/// - **Chainable**: Can add `or_else` branch to create if-then-else logic
34///
35/// # Author
36///
37/// Haixing Hu
38pub struct ArcConditionalBiMutatingFunction<T, U, R> {
39 pub(super) function: ArcBiMutatingFunction<T, U, R>,
40 pub(super) predicate: ArcBiPredicate<T, U>,
41}
42
43// Implement ArcConditionalBiMutatingFunction
44impl_shared_conditional_function!(
45 ArcConditionalBiMutatingFunction<T, U, R>,
46 ArcBiMutatingFunction,
47 BiMutatingFunction,
48 into_arc,
49 Send + Sync + 'static
50);
51
52// Use macro to generate Debug and Display implementations
53impl_conditional_function_debug_display!(ArcConditionalBiMutatingFunction<T, U, R>);
54
55// Generate Clone implementation
56impl_conditional_function_clone!(ArcConditionalBiMutatingFunction<T, U, R>);