pub struct Mapper<T>(pub T);
pub trait MapFn<Input> {
type Output;
fn map(&mut self, input: Input) -> Self::Output;
}
impl<Input, Output, F> MapFn<Input> for Mapper<F>
where
F: MapFn<Input, Output = Output>,
{
type Output = Output;
fn map(&mut self, input: Input) -> Self::Output {
let Self(mapper) = self;
mapper.map(input)
}
}
impl<Input, Output, F> MapFn<Input> for &mut F
where
F: MapFn<Input, Output = Output>,
{
type Output = Output;
fn map(&mut self, input: Input) -> Self::Output {
(**self).map(input)
}
}