pub struct BoxBiTransformerOnce<T, U, R> { /* private fields */ }Expand description
BoxBiTransformerOnce - consuming bi-transformer wrapper based on
Box<dyn FnOnce>
A bi-transformer wrapper that provides single ownership with one-time use semantics. Consumes self and both input values.
§Features
- Based on:
Box<dyn FnOnce(T, U) -> R> - Ownership: Single ownership, cannot be cloned
- Reusability: Can only be called once (consumes self and inputs)
- Thread Safety: Not thread-safe (no
Send + Syncrequirement)
Implementations§
Source§impl<T, U, R> BoxBiTransformerOnce<T, U, R>
impl<T, U, R> BoxBiTransformerOnce<T, U, R>
Sourcepub fn new<F>(f: F) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
pub fn new<F>(f: F) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
Creates a new bi-transformer.
Wraps the provided closure in the appropriate smart pointer type for this bi-transformer implementation.
Examples found in repository?
19fn main() {
20 println!("=== BoxBiTransformerOnce and_then Method Example ===\n");
21
22 // Example 1: Basic and_then usage
23 println!("Example 1: Basic and_then usage");
24 let add = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
25 let double = |x: i32| x * 2;
26 let composed = add.and_then(double);
27 let result = composed.apply(3, 5);
28 println!(" (3 + 5) * 2 = {}", result);
29 assert_eq!(result, 16);
30 println!();
31
32 // Example 2: Type conversion
33 println!("Example 2: Type conversion");
34 let add2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
35 let to_string = |x: i32| x.to_string();
36 let composed2 = add2.and_then(to_string);
37 let result2 = composed2.apply(20, 22);
38 println!(" (20 + 22).to_string() = \"{}\"", result2);
39 assert_eq!(result2, "42");
40 println!();
41
42 // Example 3: Multi-level chained composition
43 println!("Example 3: Multi-level chained composition");
44 let add3 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
45 let double3 = |x: i32| x * 2;
46 let to_string3 = |x: i32| format!("Result: {}", x);
47 let composed3 = add3.and_then(double3).and_then(to_string3);
48 let result3 = composed3.apply(3, 5);
49 println!(" (3 + 5) * 2 -> \"{}\"", result3);
50 assert_eq!(result3, "Result: 16");
51 println!();
52
53 // Example 4: String operations
54 println!("Example 4: String operations");
55 let concat = BoxBiTransformerOnce::new(|x: String, y: String| format!("{} {}", x, y));
56 let uppercase = |s: String| s.to_uppercase();
57 let composed4 = concat.and_then(uppercase);
58 let result4 = composed4.apply("hello".to_string(), "world".to_string());
59 println!(" \"hello\" + \"world\" -> uppercase = \"{}\"", result4);
60 assert_eq!(result4, "HELLO WORLD");
61 println!();
62
63 // Example 5: Mathematical calculation chain
64 println!("Example 5: Mathematical calculation chain");
65 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
66 let to_float = |x: i32| x as f64 / 2.0;
67 let composed5 = multiply.and_then(to_float);
68 let result5 = composed5.apply(6, 7);
69 println!(" (6 * 7) / 2.0 = {}", result5);
70 assert!((result5 - 21.0).abs() < 1e-10);
71 println!();
72
73 // Example 6: Complex business logic
74 println!("Example 6: Complex business logic");
75 let calculate_total =
76 BoxBiTransformerOnce::new(|price: f64, quantity: i32| price * quantity as f64);
77 let apply_discount = |total: f64| {
78 if total > 100.0 {
79 total * 0.9 // 10% discount
80 } else {
81 total
82 }
83 };
84 let format_price = |total: f64| format!("${:.2}", total);
85 let composed6 = calculate_total
86 .and_then(apply_discount)
87 .and_then(format_price);
88 let result6 = composed6.apply(15.5, 8);
89 println!(" Price: $15.5, Quantity: 8");
90 println!(" Total price (with discount): {}", result6);
91 assert_eq!(result6, "$111.60");
92 println!();
93
94 println!("=== All examples executed successfully! ===");
95}More examples
17fn main() {
18 println!("=== BiTransformerOnce Examples ===\n");
19
20 // Example 1: Basic usage with closure
21 println!("1. Basic usage with closure:");
22 let add = |x: i32, y: i32| x + y;
23 let result = add.apply(20, 22);
24 println!(" 20 + 22 = {}", result);
25
26 // Example 2: BoxBiTransformerOnce with new
27 println!("\n2. BoxBiTransformerOnce with new:");
28 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
29 println!(" 6 * 7 = {}", multiply.apply(6, 7));
30
31 // Example 3: Constant transformer
32 println!("\n3. Constant transformer:");
33 let constant = BoxBiTransformerOnce::constant("hello");
34 println!(" constant(123, 456) = {}", constant.apply(123, 456));
35
36 // Example 4: Consuming owned values
37 println!("\n4. Consuming owned values:");
38 let concat = BoxBiTransformerOnce::new(|x: String, y: String| format!("{} {}", x, y));
39 let s1 = String::from("hello");
40 let s2 = String::from("world");
41 let result = concat.apply(s1, s2);
42 println!(" concat('hello', 'world') = {}", result);
43
44 // Example 5: Conditional transformation with when/or_else
45 println!("\n5. Conditional transformation (positive numbers):");
46 let add = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
47 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
48 let conditional = add
49 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
50 .or_else(multiply);
51 println!(" conditional(5, 3) = {} (add)", conditional.apply(5, 3));
52
53 println!("\n6. Conditional transformation (negative numbers):");
54 let add2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
55 let multiply2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
56 let conditional2 = add2
57 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
58 .or_else(multiply2);
59 println!(
60 " conditional(-5, 3) = {} (multiply)",
61 conditional2.apply(-5, 3)
62 );
63
64 // Example 7: Conditional with closure in or_else
65 println!("\n7. Conditional with closure in or_else:");
66 let add3 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
67 let conditional3 = add3
68 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
69 .or_else(|x: i32, y: i32| x * y);
70 println!(" conditional(4, 6) = {}", conditional3.apply(4, 6));
71
72 // Example 8: Merging vectors
73 println!("\n8. Merging vectors:");
74 let merge = BoxBiTransformerOnce::new(|mut x: Vec<i32>, y: Vec<i32>| {
75 x.extend(y);
76 x
77 });
78 let v1 = vec![1, 2, 3];
79 let v2 = vec![4, 5, 6];
80 let result = merge.apply(v1, v2);
81 println!(" merge([1, 2, 3], [4, 5, 6]) = {:?}", result);
82
83 // Example 9: Complex transformation with calculation
84 println!("\n9. Complex transformation with calculation:");
85 let calculate = BoxBiTransformerOnce::new(|x: i32, y: i32| {
86 let sum = x + y;
87 let product = x * y;
88 (sum, product)
89 });
90 let (sum, product) = calculate.apply(5, 3);
91 println!(" calculate(5, 3) = (sum: {}, product: {})", sum, product);
92
93 // Example 10: String manipulation
94 println!("\n10. String manipulation:");
95 let process = BoxBiTransformerOnce::new(|x: String, y: String| {
96 format!("{} {} {}", x.to_uppercase(), "and", y.to_lowercase())
97 });
98 println!(
99 " process('Hello', 'WORLD') = {}",
100 process.apply("Hello".to_string(), "WORLD".to_string())
101 );
102
103 // Example 11: Converting to function
104 println!("\n11. Converting to function:");
105 let add4 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
106 let f = add4.into_fn();
107 println!(" f(10, 20) = {}", f(10, 20));
108
109 // Example 12: Converting to box (zero-cost)
110 println!("\n12. Converting to box (zero-cost):");
111 let add5 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
112 let boxed = add5.into_box();
113 println!(" boxed(15, 25) = {}", boxed.apply(15, 25));
114
115 println!("\n=== All examples completed successfully! ===");
116}Sourcepub fn new_with_name<F>(name: &str, f: F) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
pub fn new_with_name<F>(name: &str, f: F) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
Creates a new named bi-transformer.
Wraps the provided closure and assigns it a name, which is useful for debugging and logging purposes.
Sourcepub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
pub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Selfwhere
F: FnOnce(T, U) -> R + 'static,
Creates a new named bi-transformer with an optional name.
Wraps the provided closure and assigns it an optional name.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Gets the name of this bi-transformer.
§Returns
Returns Some(&str) if a name was set, None otherwise.
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
Clears the name of this bi-transformer.
Sourcepub fn when<P>(self, predicate: P) -> BoxConditionalBiTransformerOnce<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
P: BiPredicate<T, U> + 'static,
pub fn when<P>(self, predicate: P) -> BoxConditionalBiTransformerOnce<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
P: BiPredicate<T, U> + 'static,
Creates a conditional two-parameter transformer that executes based on bi-predicate result.
§Parameters
predicate- The bi-predicate to determine whether to execute the transformation operation
§Returns
Returns a conditional two-parameter transformer that only executes
when the predicate returns true.
§Examples
use qubit_function::transformers::*;
let bi_transformer = BoxBiTransformer::new({
|key: String, value: i32| format!("{}: {}", key, value)
});
let conditional = bi_transformer
.when(|key: &String, value: &i32| *value > 0)
.or_else(|key: String, _value: i32| key);
assert_eq!(conditional.apply("test".to_string(), 5), "test: 5".to_string()); // transformed
assert_eq!(conditional.apply("test".to_string(), -1), "test".to_string()); // identity (key unchanged)Examples found in repository?
17fn main() {
18 println!("=== BiTransformerOnce Examples ===\n");
19
20 // Example 1: Basic usage with closure
21 println!("1. Basic usage with closure:");
22 let add = |x: i32, y: i32| x + y;
23 let result = add.apply(20, 22);
24 println!(" 20 + 22 = {}", result);
25
26 // Example 2: BoxBiTransformerOnce with new
27 println!("\n2. BoxBiTransformerOnce with new:");
28 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
29 println!(" 6 * 7 = {}", multiply.apply(6, 7));
30
31 // Example 3: Constant transformer
32 println!("\n3. Constant transformer:");
33 let constant = BoxBiTransformerOnce::constant("hello");
34 println!(" constant(123, 456) = {}", constant.apply(123, 456));
35
36 // Example 4: Consuming owned values
37 println!("\n4. Consuming owned values:");
38 let concat = BoxBiTransformerOnce::new(|x: String, y: String| format!("{} {}", x, y));
39 let s1 = String::from("hello");
40 let s2 = String::from("world");
41 let result = concat.apply(s1, s2);
42 println!(" concat('hello', 'world') = {}", result);
43
44 // Example 5: Conditional transformation with when/or_else
45 println!("\n5. Conditional transformation (positive numbers):");
46 let add = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
47 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
48 let conditional = add
49 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
50 .or_else(multiply);
51 println!(" conditional(5, 3) = {} (add)", conditional.apply(5, 3));
52
53 println!("\n6. Conditional transformation (negative numbers):");
54 let add2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
55 let multiply2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
56 let conditional2 = add2
57 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
58 .or_else(multiply2);
59 println!(
60 " conditional(-5, 3) = {} (multiply)",
61 conditional2.apply(-5, 3)
62 );
63
64 // Example 7: Conditional with closure in or_else
65 println!("\n7. Conditional with closure in or_else:");
66 let add3 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
67 let conditional3 = add3
68 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
69 .or_else(|x: i32, y: i32| x * y);
70 println!(" conditional(4, 6) = {}", conditional3.apply(4, 6));
71
72 // Example 8: Merging vectors
73 println!("\n8. Merging vectors:");
74 let merge = BoxBiTransformerOnce::new(|mut x: Vec<i32>, y: Vec<i32>| {
75 x.extend(y);
76 x
77 });
78 let v1 = vec![1, 2, 3];
79 let v2 = vec![4, 5, 6];
80 let result = merge.apply(v1, v2);
81 println!(" merge([1, 2, 3], [4, 5, 6]) = {:?}", result);
82
83 // Example 9: Complex transformation with calculation
84 println!("\n9. Complex transformation with calculation:");
85 let calculate = BoxBiTransformerOnce::new(|x: i32, y: i32| {
86 let sum = x + y;
87 let product = x * y;
88 (sum, product)
89 });
90 let (sum, product) = calculate.apply(5, 3);
91 println!(" calculate(5, 3) = (sum: {}, product: {})", sum, product);
92
93 // Example 10: String manipulation
94 println!("\n10. String manipulation:");
95 let process = BoxBiTransformerOnce::new(|x: String, y: String| {
96 format!("{} {} {}", x.to_uppercase(), "and", y.to_lowercase())
97 });
98 println!(
99 " process('Hello', 'WORLD') = {}",
100 process.apply("Hello".to_string(), "WORLD".to_string())
101 );
102
103 // Example 11: Converting to function
104 println!("\n11. Converting to function:");
105 let add4 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
106 let f = add4.into_fn();
107 println!(" f(10, 20) = {}", f(10, 20));
108
109 // Example 12: Converting to box (zero-cost)
110 println!("\n12. Converting to box (zero-cost):");
111 let add5 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
112 let boxed = add5.into_box();
113 println!(" boxed(15, 25) = {}", boxed.apply(15, 25));
114
115 println!("\n=== All examples completed successfully! ===");
116}Sourcepub fn and_then<S, F>(self, after: F) -> BoxBiTransformerOnce<T, U, S>where
T: 'static,
U: 'static,
R: 'static,
S: 'static,
F: TransformerOnce<R, S> + 'static,
pub fn and_then<S, F>(self, after: F) -> BoxBiTransformerOnce<T, U, S>where
T: 'static,
U: 'static,
R: 'static,
S: 'static,
F: TransformerOnce<R, S> + 'static,
Chains execution with another two-parameter transformer, executing the current transformer first, then the subsequent transformer.
§Parameters
after- The subsequent two-parameter transformer to execute after the current transformer completes
§Returns
Returns a new two-parameter transformer that executes the current transformer and the subsequent transformer in sequence.
§Examples
use qubit_function::transformers::*;
let bi_transformer1 = BoxBiTransformer::new({
|key: String, value: i32| (key, value + 1)
});
let bi_transformer2 = BoxTransformer::new({
|value: (String, i32)| format!("{}: {}", value.0, value.1)
});
let chained = bi_transformer1.and_then(bi_transformer2);
let result = chained.apply("test".to_string(), 5);
assert_eq!(result, "test: 6"); // (value + 1) = 6Examples found in repository?
19fn main() {
20 println!("=== BoxBiTransformerOnce and_then Method Example ===\n");
21
22 // Example 1: Basic and_then usage
23 println!("Example 1: Basic and_then usage");
24 let add = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
25 let double = |x: i32| x * 2;
26 let composed = add.and_then(double);
27 let result = composed.apply(3, 5);
28 println!(" (3 + 5) * 2 = {}", result);
29 assert_eq!(result, 16);
30 println!();
31
32 // Example 2: Type conversion
33 println!("Example 2: Type conversion");
34 let add2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
35 let to_string = |x: i32| x.to_string();
36 let composed2 = add2.and_then(to_string);
37 let result2 = composed2.apply(20, 22);
38 println!(" (20 + 22).to_string() = \"{}\"", result2);
39 assert_eq!(result2, "42");
40 println!();
41
42 // Example 3: Multi-level chained composition
43 println!("Example 3: Multi-level chained composition");
44 let add3 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
45 let double3 = |x: i32| x * 2;
46 let to_string3 = |x: i32| format!("Result: {}", x);
47 let composed3 = add3.and_then(double3).and_then(to_string3);
48 let result3 = composed3.apply(3, 5);
49 println!(" (3 + 5) * 2 -> \"{}\"", result3);
50 assert_eq!(result3, "Result: 16");
51 println!();
52
53 // Example 4: String operations
54 println!("Example 4: String operations");
55 let concat = BoxBiTransformerOnce::new(|x: String, y: String| format!("{} {}", x, y));
56 let uppercase = |s: String| s.to_uppercase();
57 let composed4 = concat.and_then(uppercase);
58 let result4 = composed4.apply("hello".to_string(), "world".to_string());
59 println!(" \"hello\" + \"world\" -> uppercase = \"{}\"", result4);
60 assert_eq!(result4, "HELLO WORLD");
61 println!();
62
63 // Example 5: Mathematical calculation chain
64 println!("Example 5: Mathematical calculation chain");
65 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
66 let to_float = |x: i32| x as f64 / 2.0;
67 let composed5 = multiply.and_then(to_float);
68 let result5 = composed5.apply(6, 7);
69 println!(" (6 * 7) / 2.0 = {}", result5);
70 assert!((result5 - 21.0).abs() < 1e-10);
71 println!();
72
73 // Example 6: Complex business logic
74 println!("Example 6: Complex business logic");
75 let calculate_total =
76 BoxBiTransformerOnce::new(|price: f64, quantity: i32| price * quantity as f64);
77 let apply_discount = |total: f64| {
78 if total > 100.0 {
79 total * 0.9 // 10% discount
80 } else {
81 total
82 }
83 };
84 let format_price = |total: f64| format!("${:.2}", total);
85 let composed6 = calculate_total
86 .and_then(apply_discount)
87 .and_then(format_price);
88 let result6 = composed6.apply(15.5, 8);
89 println!(" Price: $15.5, Quantity: 8");
90 println!(" Total price (with discount): {}", result6);
91 assert_eq!(result6, "$111.60");
92 println!();
93
94 println!("=== All examples executed successfully! ===");
95}Source§impl<T, U, R> BoxBiTransformerOnce<T, U, R>
impl<T, U, R> BoxBiTransformerOnce<T, U, R>
Sourcepub fn constant(value: R) -> BoxBiTransformerOnce<T, U, R>where
R: Clone + 'static,
pub fn constant(value: R) -> BoxBiTransformerOnce<T, U, R>where
R: Clone + 'static,
Creates a constant bi-transformer
§Examples
/// rust /// use qubit_function::{BoxBiTransformerOnce, BiTransformer}; /// /// let constant = BoxBiTransformerOnce::constant("hello"); /// assert_eq!(constant.apply(123, 456), "hello"); ///
Examples found in repository?
17fn main() {
18 println!("=== BiTransformerOnce Examples ===\n");
19
20 // Example 1: Basic usage with closure
21 println!("1. Basic usage with closure:");
22 let add = |x: i32, y: i32| x + y;
23 let result = add.apply(20, 22);
24 println!(" 20 + 22 = {}", result);
25
26 // Example 2: BoxBiTransformerOnce with new
27 println!("\n2. BoxBiTransformerOnce with new:");
28 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
29 println!(" 6 * 7 = {}", multiply.apply(6, 7));
30
31 // Example 3: Constant transformer
32 println!("\n3. Constant transformer:");
33 let constant = BoxBiTransformerOnce::constant("hello");
34 println!(" constant(123, 456) = {}", constant.apply(123, 456));
35
36 // Example 4: Consuming owned values
37 println!("\n4. Consuming owned values:");
38 let concat = BoxBiTransformerOnce::new(|x: String, y: String| format!("{} {}", x, y));
39 let s1 = String::from("hello");
40 let s2 = String::from("world");
41 let result = concat.apply(s1, s2);
42 println!(" concat('hello', 'world') = {}", result);
43
44 // Example 5: Conditional transformation with when/or_else
45 println!("\n5. Conditional transformation (positive numbers):");
46 let add = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
47 let multiply = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
48 let conditional = add
49 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
50 .or_else(multiply);
51 println!(" conditional(5, 3) = {} (add)", conditional.apply(5, 3));
52
53 println!("\n6. Conditional transformation (negative numbers):");
54 let add2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
55 let multiply2 = BoxBiTransformerOnce::new(|x: i32, y: i32| x * y);
56 let conditional2 = add2
57 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
58 .or_else(multiply2);
59 println!(
60 " conditional(-5, 3) = {} (multiply)",
61 conditional2.apply(-5, 3)
62 );
63
64 // Example 7: Conditional with closure in or_else
65 println!("\n7. Conditional with closure in or_else:");
66 let add3 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
67 let conditional3 = add3
68 .when(|x: &i32, y: &i32| *x > 0 && *y > 0)
69 .or_else(|x: i32, y: i32| x * y);
70 println!(" conditional(4, 6) = {}", conditional3.apply(4, 6));
71
72 // Example 8: Merging vectors
73 println!("\n8. Merging vectors:");
74 let merge = BoxBiTransformerOnce::new(|mut x: Vec<i32>, y: Vec<i32>| {
75 x.extend(y);
76 x
77 });
78 let v1 = vec![1, 2, 3];
79 let v2 = vec![4, 5, 6];
80 let result = merge.apply(v1, v2);
81 println!(" merge([1, 2, 3], [4, 5, 6]) = {:?}", result);
82
83 // Example 9: Complex transformation with calculation
84 println!("\n9. Complex transformation with calculation:");
85 let calculate = BoxBiTransformerOnce::new(|x: i32, y: i32| {
86 let sum = x + y;
87 let product = x * y;
88 (sum, product)
89 });
90 let (sum, product) = calculate.apply(5, 3);
91 println!(" calculate(5, 3) = (sum: {}, product: {})", sum, product);
92
93 // Example 10: String manipulation
94 println!("\n10. String manipulation:");
95 let process = BoxBiTransformerOnce::new(|x: String, y: String| {
96 format!("{} {} {}", x.to_uppercase(), "and", y.to_lowercase())
97 });
98 println!(
99 " process('Hello', 'WORLD') = {}",
100 process.apply("Hello".to_string(), "WORLD".to_string())
101 );
102
103 // Example 11: Converting to function
104 println!("\n11. Converting to function:");
105 let add4 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
106 let f = add4.into_fn();
107 println!(" f(10, 20) = {}", f(10, 20));
108
109 // Example 12: Converting to box (zero-cost)
110 println!("\n12. Converting to box (zero-cost):");
111 let add5 = BoxBiTransformerOnce::new(|x: i32, y: i32| x + y);
112 let boxed = add5.into_box();
113 println!(" boxed(15, 25) = {}", boxed.apply(15, 25));
114
115 println!("\n=== All examples completed successfully! ===");
116}