use std::rc::Rc;
use std::sync::Arc;
use crate::functions::{
bi_function_once::BoxBiFunctionOnce,
function::Function,
macros::{
impl_box_conditional_function,
impl_box_function_methods,
impl_conditional_function_clone,
impl_conditional_function_debug_display,
impl_function_clone,
impl_function_common_methods,
impl_function_constant_method,
impl_function_debug_display,
impl_shared_conditional_function,
impl_shared_function_methods,
},
};
use crate::macros::{
impl_arc_conversions,
impl_box_conversions,
impl_closure_trait,
impl_rc_conversions,
};
use crate::predicates::bi_predicate::{
ArcBiPredicate,
BiPredicate,
BoxBiPredicate,
RcBiPredicate,
};
mod box_bi_function;
pub use box_bi_function::BoxBiFunction;
mod rc_bi_function;
pub use rc_bi_function::RcBiFunction;
mod arc_bi_function;
pub use arc_bi_function::ArcBiFunction;
mod fn_bi_function_ops;
pub use fn_bi_function_ops::FnBiFunctionOps;
mod box_binary_function;
pub use box_binary_function::BoxBinaryFunction;
mod arc_binary_function;
pub use arc_binary_function::ArcBinaryFunction;
mod rc_binary_function;
pub use rc_binary_function::RcBinaryFunction;
mod box_conditional_bi_function;
pub use box_conditional_bi_function::BoxConditionalBiFunction;
mod rc_conditional_bi_function;
pub use rc_conditional_bi_function::RcConditionalBiFunction;
mod arc_conditional_bi_function;
pub use arc_conditional_bi_function::ArcConditionalBiFunction;
pub trait BiFunction<T, U, R> {
fn apply(&self, first: &T, second: &U) -> R;
fn into_box(self) -> BoxBiFunction<T, U, R>
where
Self: Sized + 'static,
{
BoxBiFunction::new(move |t, u| self.apply(t, u))
}
fn into_rc(self) -> RcBiFunction<T, U, R>
where
Self: Sized + 'static,
{
RcBiFunction::new(move |t, u| self.apply(t, u))
}
fn into_arc(self) -> ArcBiFunction<T, U, R>
where
Self: Sized + Send + Sync + 'static,
{
ArcBiFunction::new(move |t, u| self.apply(t, u))
}
fn into_fn(self) -> impl Fn(&T, &U) -> R
where
Self: Sized + 'static,
{
move |t, u| self.apply(t, u)
}
fn into_once(self) -> BoxBiFunctionOnce<T, U, R>
where
Self: Sized + 'static,
{
BoxBiFunctionOnce::new(move |t, u| self.apply(t, u))
}
fn to_box(&self) -> BoxBiFunction<T, U, R>
where
Self: Sized + Clone + 'static,
{
self.clone().into_box()
}
fn to_rc(&self) -> RcBiFunction<T, U, R>
where
Self: Sized + Clone + 'static,
{
self.clone().into_rc()
}
fn to_arc(&self) -> ArcBiFunction<T, U, R>
where
Self: Sized + Clone + Send + Sync + 'static,
{
self.clone().into_arc()
}
fn to_fn(&self) -> impl Fn(&T, &U) -> R
where
Self: Sized + Clone + 'static,
{
self.clone().into_fn()
}
fn to_once(&self) -> BoxBiFunctionOnce<T, U, R>
where
Self: Clone + 'static,
{
self.clone().into_once()
}
}