#[fp_macros::document_module]
pub(crate) mod inner {
use {
crate::{
classes::{
ApplyFirst,
RefApplyFirst,
},
dispatch::{
Ref,
Val,
},
kinds::*,
},
fp_macros::*,
};
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the applicative.",
"The type of the value(s) inside the first container.",
"The type of the value(s) inside the second container.",
"Dispatch marker type, inferred automatically. Either [`Val`](crate::dispatch::Val) or [`Ref`](crate::dispatch::Ref)."
)]
#[document_parameters("The first container implementing this dispatch.")]
pub trait ApplyFirstDispatch<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, Marker> {
type FB;
#[document_signature]
#[document_parameters("The second container (its result is discarded).")]
#[document_returns("A container preserving the values from the first input.")]
#[document_examples]
fn dispatch(
self,
fb: Self::FB,
) -> 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 applicative.",
"The type of the value(s) inside the first container.",
"The type of the value(s) inside the second container."
)]
#[document_parameters("The owned first container.")]
impl<'a, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Val> for Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
Brand: ApplyFirst,
A: 'a + Clone,
B: 'a + Clone,
{
type FB = Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>);
#[document_signature]
#[document_parameters("The second container (its result is discarded).")]
#[document_returns("A container preserving the values from the first input.")]
#[document_examples]
fn dispatch(
self,
fb: Self::FB,
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>) {
Brand::apply_first(self, fb)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The borrow lifetime.",
"The brand of the applicative.",
"The type of the value(s) inside the first container.",
"The type of the value(s) inside the second container."
)]
#[document_parameters("The borrowed first container.")]
impl<'a, 'b, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Ref> for &'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
'a: 'b,
Brand: RefApplyFirst,
A: 'a + Clone,
B: 'a,
{
type FB = &'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>);
#[document_signature]
#[document_parameters("The second borrowed container (its result is discarded).")]
#[document_returns("A container preserving the values from the first input.")]
#[document_examples]
fn dispatch(
self,
fb: Self::FB,
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>) {
Brand::ref_apply_first(self, fb)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The first container type (owned or borrowed). Brand is inferred from this.",
"The type of the value(s) inside the first container.",
"The type of the value(s) inside the second container.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The first container (its values are preserved).",
"The second container (its values are discarded)."
)]
#[document_returns("A container preserving the values from the first input.")]
#[document_examples]
pub fn apply_first<'a, FA, A: 'a, B: 'a, Marker>(
fa: FA,
fb: <FA as ApplyFirstDispatch<
'a,
<FA as InferableBrand_cdc7cd43dac7585f>::Brand,
A,
B,
Marker,
>>::FB,
) -> <<FA as InferableBrand_cdc7cd43dac7585f>::Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where
FA: InferableBrand_cdc7cd43dac7585f
+ ApplyFirstDispatch<'a, <FA as InferableBrand_cdc7cd43dac7585f>::Brand, A, B, Marker>, {
fa.dispatch(fb)
}
pub mod explicit {
use super::*;
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the applicative.",
"The type of the value(s) inside the first container.",
"The type of the value(s) inside the second container.",
"The first container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The first container (its values are preserved).",
"The second container (its values are discarded)."
)]
#[document_returns("A container preserving the values from the first input.")]
#[document_examples]
pub fn apply_first<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker>(
fa: FA,
fb: <FA as ApplyFirstDispatch<'a, Brand, A, B, Marker>>::FB,
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>)
where
FA: ApplyFirstDispatch<'a, Brand, A, B, Marker>, {
fa.dispatch(fb)
}
}
}
pub use inner::*;