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