use std::rc::Rc;
use std::sync::Arc;
use crate::macros::{
impl_arc_conversions,
impl_box_conversions,
impl_rc_conversions,
};
use crate::predicates::bi_predicate::{
ArcBiPredicate,
BiPredicate,
BoxBiPredicate,
RcBiPredicate,
};
use crate::transformers::{
bi_transformer_once::BoxBiTransformerOnce,
macros::{
impl_box_conditional_transformer,
impl_box_transformer_methods,
impl_conditional_transformer_clone,
impl_conditional_transformer_debug_display,
impl_shared_conditional_transformer,
impl_shared_transformer_methods,
impl_transformer_clone,
impl_transformer_common_methods,
impl_transformer_constant_method,
impl_transformer_debug_display,
},
transformer::Transformer,
};
mod box_bi_transformer;
pub use box_bi_transformer::BoxBiTransformer;
mod rc_bi_transformer;
pub use rc_bi_transformer::RcBiTransformer;
mod arc_bi_transformer;
pub use arc_bi_transformer::ArcBiTransformer;
mod fn_bi_transformer_ops;
pub use fn_bi_transformer_ops::FnBiTransformerOps;
mod binary_operator;
pub use binary_operator::BinaryOperator;
mod box_binary_operator;
pub use box_binary_operator::BoxBinaryOperator;
mod arc_binary_operator;
pub use arc_binary_operator::ArcBinaryOperator;
mod rc_binary_operator;
pub use rc_binary_operator::RcBinaryOperator;
mod box_conditional_bi_transformer;
pub use box_conditional_bi_transformer::BoxConditionalBiTransformer;
mod rc_conditional_bi_transformer;
pub use rc_conditional_bi_transformer::RcConditionalBiTransformer;
mod arc_conditional_bi_transformer;
pub use arc_conditional_bi_transformer::ArcConditionalBiTransformer;
pub trait BiTransformer<T, U, R> {
fn apply(&self, first: T, second: U) -> R;
fn into_box(self) -> BoxBiTransformer<T, U, R>
where
Self: Sized + 'static,
{
BoxBiTransformer::new(move |x, y| self.apply(x, y))
}
fn into_rc(self) -> RcBiTransformer<T, U, R>
where
Self: Sized + 'static,
{
RcBiTransformer::new(move |x, y| self.apply(x, y))
}
fn into_arc(self) -> ArcBiTransformer<T, U, R>
where
Self: Sized + Send + Sync + 'static,
{
ArcBiTransformer::new(move |x, y| self.apply(x, y))
}
fn into_fn(self) -> impl Fn(T, U) -> R
where
Self: Sized + 'static,
{
move |t, u| self.apply(t, u)
}
fn into_once(self) -> BoxBiTransformerOnce<T, U, R>
where
Self: Sized + 'static,
{
BoxBiTransformerOnce::new(move |t, u| self.apply(t, u))
}
fn to_box(&self) -> BoxBiTransformer<T, U, R>
where
Self: Sized + Clone + 'static,
{
self.clone().into_box()
}
fn to_rc(&self) -> RcBiTransformer<T, U, R>
where
Self: Sized + Clone + 'static,
{
self.clone().into_rc()
}
fn to_arc(&self) -> ArcBiTransformer<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) -> BoxBiTransformerOnce<T, U, R>
where
Self: Clone + 'static,
{
self.clone().into_once()
}
}