Skip to main content

qubit_function/functions/bi_function/
box_binary_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 `BoxBinaryFunction` public type.
12
13#![allow(unused_imports)]
14
15use super::*;
16
17// ============================================================================
18// Type Aliases for BinaryOperator (BiFunction<T, T, R>)
19// ============================================================================
20
21/// Type alias for `BoxBiFunction<T, T, R>`
22///
23/// Represents a binary function that takes two values of type `T` and produces
24/// a value of type `R`, with single ownership semantics. Similar to Java's
25/// `BiFunction<T, T, R>` but with different type parameters.
26///
27/// # Examples
28///
29/// ```rust
30/// use qubit_function::{BoxBinaryFunction, BiFunction};
31///
32/// let add: BoxBinaryFunction<i32, i32> = BoxBinaryFunction::new(|x, y| *x + *y);
33/// assert_eq!(add.apply(&20, &22), 42);
34/// ```
35///
36pub type BoxBinaryFunction<T, R> = BoxBiFunction<T, T, R>;