#[fp_macros::document_module]
pub(crate) mod inner {
use {
crate::{
classes::{
Alt,
RefAlt,
},
dispatch::{
Ref,
Val,
},
kinds::*,
},
fp_macros::*,
};
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the functor.",
"The type of the value(s) inside the functor.",
"Dispatch marker type, inferred automatically. Either [`Val`](crate::dispatch::Val) or [`Ref`](crate::dispatch::Ref)."
)]
#[document_parameters("The container implementing this dispatch.")]
pub trait AltDispatch<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a + Clone, Marker> {
#[document_signature]
#[document_parameters("The other container to combine with.")]
#[document_returns("A new container from the combination of both inputs.")]
#[document_examples]
fn dispatch(
self,
other: Self,
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>);
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the functor.",
"The type of the value(s) inside the functor."
)]
#[document_parameters("The owned container.")]
impl<'a, Brand, A> AltDispatch<'a, Brand, A, Val> for Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
Brand: Alt,
A: 'a + Clone,
{
#[document_signature]
#[document_parameters("The other container to combine with.")]
#[document_returns("A new container from the combination of both inputs.")]
#[document_examples]
fn dispatch(
self,
other: Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>) {
Brand::alt(self, other)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the functor.",
"The type of the value(s) inside the functor."
)]
#[document_parameters("The borrowed container.")]
impl<'a, Brand, A> AltDispatch<'a, Brand, A, Ref> for &Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
Brand: RefAlt,
A: 'a + Clone,
{
#[document_signature]
#[document_parameters("The other borrowed container to combine with.")]
#[document_returns("A new container from the combination of both inputs.")]
#[document_examples]
fn dispatch(
self,
other: &Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>) {
Brand::ref_alt(self, other)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The container type (owned or borrowed). Brand is inferred from this.",
"The type of the value(s) inside the functor.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The first container (owned or borrowed).",
"The second container (same ownership as the first)."
)]
#[document_returns("A new container from the combination of both inputs.")]
#[document_examples]
pub fn alt<'a, FA, A: 'a + Clone, Marker>(
fa1: FA,
fa2: FA,
) -> <<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where
FA: InferableBrand_cdc7cd43dac7585f
+ AltDispatch<'a, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, A, Marker>, {
fa1.dispatch(fa2)
}
pub mod explicit {
use super::*;
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the functor.",
"The type of the value(s) inside the functor.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters("The first container.", "The second container.")]
#[document_returns("A new container from the combination of both inputs.")]
#[document_examples]
pub fn alt<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a + Clone, FA, Marker>(
fa1: FA,
fa2: FA,
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
FA: AltDispatch<'a, Brand, A, Marker>, {
fa1.dispatch(fa2)
}
}
}
pub use inner::*;